WordPress仅在一个页面上显示一个类别,摘录
问题描述:
我有一个页面设置为仅显示来自一个类别的帖子,我使用php query_posts函数调用该类别。我如何制作,以便帖子只显示为摘录,而不是完整的文章?WordPress仅在一个页面上显示一个类别,摘录
下面是我使用的页面上的代码:
<?php query_posts('category_name=news&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php endwhile;?>
*纳入WordPresses摘抄功能:
<?php query_posts('category_name=news&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt(); ?>
<?php endwhile;?>
现在我看到的第一个,我想跟着摘录名单通过重复的帖子在整体...
答
有一个核心的Wordpress方法,确切地做到这一点:
http://codex.wordpress.org/Function_Reference/the_excerpt
,并控制摘录的长度:
http://codex.wordpress.org/Function_Reference/the_excerpt#Control_Excerpt_Length_using_Filters
看来我是在张贴问题草率。我知道WordPress提供了这种方法,但我还没有尝试过。谢谢! – blackessej 2012-03-24 22:37:00
不客气:) – Spyros 2012-03-24 22:41:09
我想知道你是否仍然无法帮助我。现在我得到了这两个摘录,然后所有的帖子都在后面。我已经在问题中推荐了我的代码... – blackessej 2012-03-24 22:48:00