get all posts from a custom post type

You can use wp_query() for this to work

$args = array(
        'post_type' => 'auction',
        'posts_per_page' => -1
    )
$query = new WP_Query($args);
if ($query->have_posts() ) : 
    echo '<select>';
    while ( $query->have_posts() ) : $query->the_post();
            echo '<option value="' . get_the_ID() . '">' . get_the_title() . '</option>';
    endwhile;
    echo '</select>';
    wp_reset_postdata();
endif;

Documentation for WP_Query https://codex.wordpress.org/Class_Reference/WP_Query

Leave a Comment