有没有一种方法,在默认情况下,它会以最新的顺序显示我的帖子。put说,如果他们正在寻找一篇关于体育的博客文章,那么他们可以点击一个选项,我会将这个选项放在页面的一侧,允许他们显示所有的体育博客文章。
我不知道这是由wordpress中的标签还是类别来完成的。有没有插件可以帮我做到这一点?或者仅仅是标准的php代码?
发布于 2013-01-04 00:56:23
默认情况下,该功能在wordpress中。
发布于 2013-01-03 23:14:50
模板文件中类似以下内容的内容将对其进行排序:
$args=array(
'orderby' => 'post_date',
'order' => 'DESC'
);WP Codex - http://codex.wordpress.org/Function_Reference/query_posts上极好的参考指南
所以:-
<?php
$args=array(
'orderby' => 'post_date',
'order' => 'DESC',
);
$recent_posts = get_posts($args);
foreach( $recent_posts as $recent ){
?>
<?php
$mypages = get_post( $recent->ID );
$name = $mypages->post_name;
$content = $mypages->post_content;
?>
<?php if(has_post_thumbnail()) : ?>
<div class="thumb">
<?php the_post_thumbnail(); ?>
</div>
<?php else : ?>
<div class="thumb">
<img src="aDefaultImage.jpg" />
</div>
<?php endif; ?>
<p><?php the_date('jS F Y','<span class="date">','</span><br />'); ?>
<?php echo $content; ?></p>
<?php } ?>https://stackoverflow.com/questions/14140613
复制相似问题