Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter crystalndevr

    (@crystalndevr)

    I wanted to update this with an answer that seemed to finally worked for me …. the options_cb didn’t seem to work but actually calling the function then wrapping the name and value data within their own arrays:

    array(
        'name'    => 'Select Assistant',
        'desc'     => "The assistant's name",
        'id'          => 'mts-assistant',
        'type'      => 'select',
        'options' => show_assistant_options(),
    ),

    // Callback function

    function show_assistant_options() {
    	$titles = [];
    	$query = new WP_Query(
    		$array = array(
    			'post_type'                 => 'team',
    			'status'                       => 'publish',
    			'ignore_sticky_posts' => 1,
    			'posts_per_page'       => -1,
    			'category_name'        => 'mts-assistant'
    		 )
    	);
    	if ( $query->have_posts() ) {
    		while ( $query->have_posts() ) {
    				$query->the_post();
    				$titles[] = array(
    					'value' => get_the_id(),
    					'name' => get_the_title(),
    			);
    		}
    	}
    	wp_reset_postdata();
    	return $titles;
    }

    Thread Starter crystalndevr

    (@crystalndevr)

    Hi Justin,

    Thanks for replying. The issue is that the select down menu is not displaying any choices… Also, if I replace the options I have with what you posted I get this error:

    Warning: illegal string offset ‘value’ ….

Viewing 2 replies - 1 through 2 (of 2 total)