• I want to have a metabox in de post admin area with a dropdown list of some custom post type. To make a dropdown list I need to retrieve all custom post type outside the loop in my functions file. I use this code to get the post list

    <ul>
    <?php
    global $post;
    $args = array( 'post_type' => 'vacature');
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<li><?php the_title(); ?></li>
    <?php endforeach; ?>
    </ul>

    I want the titles of the posts to store in a variable so I can use that variable as option for the select in my metabox. Is it possible to store this line of code
    <li><?php the_title(); ?></li> in a variable as an array so I retrieve all custom post types?

  • The topic ‘List posts in metabox’ is closed to new replies.