Set default option in dropdown of WP_Query?

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?

Read more here:: Set default option in dropdown of WP_Query?

Leave a Reply

Your email address will not be published. Required fields are marked *