因此,我在get\\u页面中有一个foreach循环,它显示父ID中的子页面列表。
标题、特色图片和链接都很好,但我根本无法找到摘录。我在引用http://codex.wordpress.org/Function_Reference/get_pages
$args = array(
\'child_of\' => 16,
\'title_li\' => \'\',
\'depth\' => 0,
\'sort_order\' => \'DESC\',
\'sort_column\' => \'menu_order\'
);
$pages = get_pages( $args );
$output = \'\';
foreach($pages as $value){
$thumb = get_the_post_thumbnail( $value->ID, $attr = \'\' );
$output .= "<div class=\'case-studies-parent\'><div class=\'inner\'>";
$output .= "<div class=\'image\'><a href=\'" . $value->post_name . "\' >" . $thumb . "</a> </div>";
$output .= "<div class=\'title\'><a href=\'" . $value->post_name . "\' >" . $value->post_title . "</a></div>";
$output .= "<div class=\'excerpt\'>". $value->post_excerpt . "</div>";
$output .= "</div></div>";
}
echo $output;
我可以改变
$value->post_excerpt
到
$value->post_content
这样可以正确地显示整个页面的内容。
我也尝试过各种变化,包括get_the_excerpt()
, the_excerpt()
和post_excerpt
但无济于事。
我有什么遗漏吗?在Codex页面上post_excerpt
列为正确的回报,所以我真的不知道为什么它没有显示。(顺便说一下,是的,我已经在我的页面中添加了更多标签)
更新时间:var_dump($value)
object(WP_Post)[276]
public \'ID\' => int 155
public \'post_author\' => string \'1\' (length=1)
public \'post_date\' => string \'2014-08-07 09:40:53\' (length=19)
public \'post_date_gmt\' => string \'2014-08-07 09:40:53\' (length=19)
public \'post_content\' => string \'<h2>Mobile phone tracking</h2>
<p><span>Parents keen to know the location of their children, and businesses seeking to ensure safety of lone workers have since 2004, been able to purchase a mobile phone tracking service, designed and implemented by InverOak, in conjunction with Cybit for The Carphone Warehouse.</span></p>
<p>The Carphone Warehouse, Europe\'s leading independent retailer of mobile phones and services, asked InverOak to design a system that tracks the location of any mobile phone in the UK, \'... (length=2656)
public \'post_title\' => string \'The Carphone Warehouse\' (length=22)
public \'post_excerpt\' => string \'\' (length=0)
public \'post_status\' => string \'publish\' (length=7)
public \'comment_status\' => string \'closed\' (length=6)
public \'ping_status\' => string \'closed\' (length=6)
public \'post_password\' => string \'\' (length=0)
public \'post_name\' => string \'the-carphone-warehouse\' (length=22)
public \'to_ping\' => string \'\' (length=0)
public \'pinged\' => string \'\' (length=0)
public \'post_modified\' => string \'2014-08-11 10:01:34\' (length=19)
public \'post_modified_gmt\' => string \'2014-08-11 10:01:34\' (length=19)
public \'post_content_filtered\' => string \'\' (length=0)
public \'post_parent\' => int 16
public \'guid\' => string \'http://inveroak.local/?page_id=155\' (length=34)
public \'menu_order\' => int 0
public \'post_type\' => string \'page\' (length=4)
public \'post_mime_type\' => string \'\' (length=0)
public \'comment_count\' => string \'0\' (length=1)
public \'filter\' => string \'raw\' (length=3)
因此,post\\u摘录为空。但我不完全理解为什么,如果它包含在抄本的回报中?
更新:我发现3.1中删除了页面的摘录,并在主题函数中添加了手动摘录函数。php文件:
add_post_type_support( \'page\', \'excerpt\' );
虽然这看起来不错,但这与在编辑器中使用标记有什么区别吗?哪个更干净?