我已经为WordPress安装了新的214主题。我不知道如何在我的首页上添加帖子的摘要文本。
所有旧教程,如this 不适用于新主题。
有没有关于如何解决这个问题的建议
214个索引页调用
get_template_part( \'content\', get_post_format() );
在回路内部。因此,循环的内容驻留在名为content-{$post\\u format}的模板文件中。php。所有没有帖子格式的帖子都使用内容。php显示post数据如果你看内容。php,这些行是检索和显示内容的地方
<?php if ( is_search() ) : ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php
the_content( __( \'Continue reading <span class="meta-nav">→</span>\', \'twentyfourteen\' ) );
wp_link_pages( array(
\'before\' => \'<div class="page-links"><span class="page-links-title">\' . __( \'Pages:\', \'twentyfourteen\' ) . \'</span>\',
\'after\' => \'</div>\',
\'link_before\' => \'<span>\',
\'link_after\' => \'</span>\',
) );
?>
</div><!-- .entry-content -->
<?php endif; ?>
默认情况下,除搜索页面外,所有页面上都会显示完整的帖子内容。要在主页上显示摘录,您需要修改这段代码。你所需要做的就是告诉wordpress,当你在主页上时(有条件标记is_home
), 显示摘录而不是全部内容。只需更改此行
<?php if ( is_search() ) : ?>
至<?php if ( is_search() || is_home() ) : ?>
EDIT
请记住在child theme. 永远不要更改主题本身EDIT 2
如果您使用的是静态首页,那么应该使用is_front_page()
而不是is_home()
. 去看看如何利用Conditional Tags. 然后你应该试试<?php if ( is_search() || is_front_page() ) : ?>
有关摘录的信息,请查看我的(几乎完成)post on excerpts我的“阅读更多”按钮链接到当前页面,而不是它应该链接到的摘录页面。这是我在函数中的函数。php文件:function new_excerpt_more($more) { global $post; return \' <a href=\"\'. get_permalink($post->ID) . \'\"> ...Read More</a>\'; } add_filter(\'excerpt_more\', \'new_excerpt_
214个索引页调用
get_template_part( \'content\', get_post_format() );
在回路内部。因此,循环的内容驻留在名为content-{$post\\u format}的模板文件中。php。所有没有帖子格式的帖子都使用内容。php显示post数据如果你看内容。php,这些行是检索和显示内容的地方
<?php if ( is_search() ) : ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php
the_content( __( \'Continue reading <span class="meta-nav">→</span>\', \'twentyfourteen\' ) );
wp_link_pages( array(
\'before\' => \'<div class="page-links"><span class="page-links-title">\' . __( \'Pages:\', \'twentyfourteen\' ) . \'</span>\',
\'after\' => \'</div>\',
\'link_before\' => \'<span>\',
\'link_after\' => \'</span>\',
) );
?>
</div><!-- .entry-content -->
<?php endif; ?>
默认情况下,除搜索页面外,所有页面上都会显示完整的帖子内容。要在主页上显示摘录,您需要修改这段代码。你所需要做的就是告诉wordpress,当你在主页上时(有条件标记is_home
), 显示摘录而不是全部内容。只需更改此行
<?php if ( is_search() ) : ?>
至<?php if ( is_search() || is_home() ) : ?>
EDIT
请记住在child theme. 永远不要更改主题本身EDIT 2
如果您使用的是静态首页,那么应该使用is_front_page()
而不是is_home()
. 去看看如何利用Conditional Tags. 然后你应该试试<?php if ( is_search() || is_front_page() ) : ?>
有关摘录的信息,请查看我的(几乎完成)post on excerpts有没有一种简单的方法可以让特定的分类页面显示x字数的摘录,然后通过阅读更多链接链接到完整的文章?我已经尝试了高级摘录插件,它可以满足我的需要,但我希望能够将其限制在某些类别