2016-07-19 241 views
0

我将以下代码与ACF结合使用来列出当前页面的子页面。按字母顺序排列Wordpress列表

我可以强制这个按字母顺序列出吗?

<?php 
        $this_page_id=$wp_query->post->ID;; 
        $args=array(
         'post_parent' => $this_page_id, 
         '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; } else {?> 
         <h1>Sorry we have no documentation available.</h1> 
         <?php } ?> 
         </ul> 
        <?php wp_reset_query();?> 

有可能是这种愚弄,但我已经看到了那些的标记是我有什么不同,我无法弄清楚如何使它发挥作用。

回答

1

变化the_title到标题中

$args=array(
    'post_parent' => $this_page_id, 
    'post_type' => 'page', 
    'orderby' => 'title ', //changed 
    'order' => 'ASC', // updated 
); 

称号,是在WP默认的排序参数,一个你可以看到他们here

+0

感谢,也需要。 'order'=>'ASC' –