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


Updated May 10, 2017 06:08 AM

Updated September 21, 2017 09:08 AM

Updated July 24, 2015 13:03 PM

Updated March 08, 2018 10:08 AM

Updated July 20, 2015 17:03 PM