• Resolved richer_image

    (@richer_image)


    Hi

    I’m trying to output a list of custom_post_type posts as options for a select field (having the ID as the option value and the title as the option display)

    I’m getting an Uncaught Error: Call to undefined function cmb2_get_post_options()

    (Full error message at end of post)

    Can you help? Thanks.

    function dhp_cpt_developments_list() {
      return cmb2_get_post_options( 
        array( 
          'post_type'   => 'dhp_cpt_developments', 
          'numberposts' => 100,
          'orderby'	    => 'title', 
          'order' 	    => 'ASC'
        ));
    }
    $dhp_mb_dev->add_field( array(
      'name'       => __( 'Developments', 'dhp' ),
      'id'         => $prefix . 'developments',
      'type'       => 'select',
      'show_option_none' => true,
      'options_cb'       => 'dhp_cpt_developments_list',
    ) );

    Fatal error: Uncaught Error: Call to undefined function cmb2_get_post_options() in /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/mb/dhp_mb_dev_info.php:19 Stack trace: #0 /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/classes/cmb2/includes/CMB2_Field.php(1107): dhp_cpt_developments_list(Object(CMB2_Field)) #1 /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/classes/cmb2/includes/CMB2_Field.php(1086): CMB2_Field->set_options() #2 /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/classes/cmb2/includes/types/CMB2_Type_Multi_Base.php(90): CMB2_Field->options() #3 /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/classes/cmb2/includes/types/CMB2_Type_Select.php(21): CMB2_Type_Multi_Base->concat_items() #4 /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/classes/cmb2/includes/CMB2_Types.php(601): CMB2_Type_Select->render() #5 /Users/richardbarratt/ in /Users/richardbarratt/Documents/Builds/portal/wp-content/plugins/dh_portal/inc/mb/dhp_mb_dev_info.php on line 19

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Error in producing post list as select field options’ is closed to new replies.