wordpress查询获取文章、页面

[php]
<?
//获取特定分类文章名称
query_posts(‘cat=15&showposts=10’);//如果不设定文章显示数量,默认显示5篇
//获取相关页面
query_posts(‘p=3’);//page_id=3
query_posts(‘page_id=3’);
query_posts(‘pagename=about’);
//从主页中移除特定分类,本例中移除ID为3的分类
if(is_home()){
query_posts(‘cat=-3’);
}
//获取文章,采用循环
$posts=get_posts(‘numberposts=15,category=,off=,orderby=,category_name=’);
foreach($posts as $post):
setup_postdata($post);
the_permalink();//获取文章链接
the_title();//获取文章标题
the_content();//获取文章内容
endforeach;

?>

[/php]

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据