我需要您的帮助我的WordPress小部件类型代码。我有一个名为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 :(得分: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>