I am using the following code to list sub pages of a particular page.
How would I change ot to sort by alphabetical order?
<?php $args=array(
'post_parent' => 15901,
'post_type' => 'page',
'orderby' => 'the_title',
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) { ?>
<ul>
<?php
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><h4><a href="<?php the_permalink() ?>">
<?php $brand_name = get_post_meta($post->ID, 'brand_name', true); ?><?php echo $brand_name; ?>
</a></h4>
</li>
<?php endwhile; } ?>
</ul>
<?php wp_reset_query();?>
title
, notthe_title
query_posts
call, you want to usewp_reset_postdata
instead, and you need to call at the end of the if statement, not after it ( it cleans up after calls to$my_query->the_post()
)get_the_ID()
instead