PHP Wordpress:在任何Wordpress页面上显示最新的博客帖子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Wordpress:在任何Wordpress页面上显示最新的博客帖子相关的知识,希望对你有一定的参考价值。

<?php
$args = array( 'posts_per_page' => 10, 'order'=> 'ASC', 'orderby' => 'title' );
$postslist = get_posts( $args );
foreach ($postslist as $post) :  setup_postdata($post); ?> 
	<div>
		<?php the_time(); ?>
		<?php the_title(); ?>   
		<?php the_excerpt(); ?>
                <?php the_category(', '); ?>
	</div>
<?php endforeach; ?>



Notice the div around the_time, the_title, the_excerpt and the_category. You can wrap html elements to fit and style any of these functions.

the_time will display the time of the post. use the_time instead of the_date.
http://codex.wordpress.org/Formatting_Date_and_Time

the_title will display the post title.

the_excerpt will display the post excerpt which defaults to 55 characters unless specified by a filter in functions.php. currently the twenty-ten theme sets the excerpt character limit.

the_category will display which categories the post is in, if any.

以上是关于PHP Wordpress:在任何Wordpress页面上显示最新的博客帖子的主要内容,如果未能解决你的问题,请参考以下文章

WPScan扫描Wordpress漏洞

资源变现小程序源码及搭建教程

分类层次结构不起作用 [Wordpress]

php 查询帖子类型wordpres

php Wordpres检索密码电子邮件

php 儿童主题的Wordpres功能