wordpress调用最新文章函数(可指定分类) 在wordpress中调用最新文章有很多函数像最常用的wp_get_archvies函数就可以调用网站指定前多少条记录了.
1. 调用网站所有文章只最新10条记录 ,代码如下:
<?php get_archives(‘postbypost’, 10); ?> 或如下代码:
<?php wp_get_archives(‘type=postbypost&limit=10&format=custom’); ?>
上面是调用最新10条记录,只不过是全站的.
2.调用指定分类最新文件 ,代码如下:
<?php $posts = get_posts( "category=4&numberposts=10" ); ?> <?php if ( $posts ) : ?> <ul><?php foreach ( $posts as $post ) : setup_postdata( $post ); ?> <li> <a href= "<?php the_p(www.111cn.net)ermalink() ?>" rel= "bookmark" title= "<?php the_title(); ?>" ><?php the_title(); ?></a> </li> <?php endforeach ; ?> </ul> <?php endif ; ?>或者使用wordpress强大的API功能,代码如下:
<ul> <?php query_posts( 'cat=15&posts_per_page=10' ); while (have_posts()): the_post(); ?> <li><a href= "<?php the_permalink();?>" ><?php the_title();?></a></li> <?php endwhile ; wp_reset_query(); ?> </ul>查看更多关于wordpress调用最新文章函数(可指定分类) - WordPres的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did9048