[英]Wordpress, i dont get an excerpt
I have some pages, where i filled in some text, however, in this loop i've builted, It doesn't ouput an excerpt, can figure out why ? 我有一些页面,我在其中填充了一些文本,但是,在我构建的此循环中,它不提供摘录,可以找出原因吗?
The script: 剧本:
<?php
$pageChildren = get_pages('sort_column=menu_order&number=5&hierarchical=0&child_of=16');
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
?>
<div class="four columns rightbox">
<div class="panelbox">
<?php echo '<h2><a href="' . get_permalink($pageChild->ID) . '">'. $pageChild->post_title.'</a></h2>'; ?>
<?php
if (!empty($pageChild->post_excerpt)){
echo '<p><a href="' . get_permalink($pageChild->ID) . '">' . $pageChild->post_excerpt.'</a> </p> ';
}
?>
</div>
</div>
<?php
}
}
?>
You can try it. 你可以试试。
<?php the_excerpt(); ?>
or 要么
<?php the_excerpt(80); ?>
* 80 is a word Limit. * 80是字数限制。
Add code in your function.php
在您的function.php中添加代码
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
select 'excerpt' option in screenoption on page header.
在页面标题的屏幕选项中选择“摘录”选项。 and add page excerpt content.
并添加页面摘录内容。
In WordPress the excerpt
is a feature for posts, pages have the post_excerpt
property but it is only because they share the same database fields as the posts. 在WordPress中
the excerpt
是帖子的功能,页面具有post_excerpt
属性,但这仅是因为它们与帖子共享相同的数据库字段。 If you want to enable excerpt area for your pages put the following code in functions.php. 如果要为页面启用摘录区域,请将以下代码放在functions.php中。
add_action( 'init', 'add_pages_excerpts' );
function add_pages_excerpts() {
add_post_type_support( 'page', 'excerpt' );
}
Now there should be 'Excerpt' area in 'Admin->New Page' ( if not, open the screen options at the right top corner and click on 'Excerpt' checkbox ). 现在,在“管理员”->“新建页面”中应该有“摘录”区域(如果没有,请打开右上角的屏幕选项,然后单击“摘录”复选框)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.