2012-04-25 212 views
0

我需要你的幫助與我的窗口部件類型代碼。我有一個名爲ordermetakey的自定義字段。我需要下面的這個框來對這個自定義字段ASC上的帖子進行排序。它的數字爲timestamp排序自定義字段

<div class="list-block"> 
    <ul> 
     <?php $postslist = get_posts('numberposts=5'); foreach ($postslist as $post) : setup_postdata($post); ?> 
     <li> 
      <p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p> 
     </li> 
    <?php endforeach; ?> 
    </ul> 
</div> 

回答

0
<div class="list-block"> 
    <ul> 
     <?php $postslist = get_posts(array(
      'meta_key' => 'ordermetakey', 
      'orderby' => 'meta_value_num', 
      'order' => 'ASC', 
      'posts_per_page' => 5 
     ); 
     foreach ($postslist as $post) : setup_postdata($post); ?> 
     <li> 
      <p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p> 
     </li> 
     <?php endforeach; ?> 
    </ul> 
</div>