Hello guys,
Can someone tell me if is possible to order this dropdown by name instead of id?
My code:
I need to order by post_title...
Thank you!!
Can someone tell me if is possible to order this dropdown by name instead of id?
My code:
PHP:
<select name="mr_freeGalleryModel" id="mr_freeGalleryModel">
<option value="">Select</option>
<?php
//$mr_ModelId =get_post_meta($mrpostParent,"mr_freeGalleryModel",true);
$args = array('post_type' => 'model',
'post_status' => 'publish',
'posts_per_page' => -1);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() )
{
while ($my_query->have_posts()) : $my_query->the_post();
$mdoel_id = get_the_ID();
echo '<option value="'.$mdoel_id.'">'.get_the_title().'</option>';
endwhile;
}
wp_reset_query();
?>
</select>
I need to order by post_title...
Thank you!!