Set default option in dropdown of WP_Query?

by Xero1   Last Updated August 13, 2019 23:08 PM

I have a dropbox that populates Custom Post Type titles as an option. It uses WP Query to pull those titles from Wordpress.

<select name="propname">
    <?php
        if($the_query->have_posts()){
            while($the_query->have_posts()) : $the_query->the_post(); ?>
                <option><?php the_title(); ?></option>
            <?php endwhile; 
        } wp_reset_query();
    ?>
</select>

How do I have it so that on the page I am currently on (one of the CPT pages in the dropdown) is the one in the dropdown already selected?



Related Questions


Drop Down not able to add dropdown

Updated May 10, 2017 06:08 AM




Fill form from Dropdown

Updated July 20, 2015 17:03 PM