我想做的是:
我有一篇博客文章,我只想显示到某个特定的点。所以在我的帖子里

<!--more-->

在正确的位置。
我的content.php如下所示:
<div class="entry-content">
    <?php the_content('read more'); ?>
</div><!-- .entry-content -->

<footer class="entry-footer">
    <?php mytheme_entry_footer(); ?>
</footer><!-- .entry-footer -->

“read more”链接会显示在内容的后面。但是我怎样才能在带有“注释”链接的条目页脚中显示它呢?
节选有什么解决办法吗?
<?php the_excerpt(); ?>

我想这样会更好,因为我不需要在每一个帖子里都写上这句话。

最佳答案

您可以使用functions.php中的以下筛选器删除“读取更多信息”:

add_filter( 'the_content_more_link', 'remove_more_link', 10, 2 );

function remove_more_link( $more_link, $more_link_text ) {
    return;
}

现在您可以在条目页脚中创建自己的“阅读更多”链接:
<footer class="entry-footer">
    <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a>
    <?php mytheme_entry_footer(); ?>
</footer><!-- .entry-footer -->

编辑:
在以下评论中,提出了以下问题:
我使用的是“节选”而不是“内容”。如果帖子太长,是否可以只显示链接?
您可以通过检查摘录是否与内容不同来完成此操作。如果是这种情况(因此内容比摘录显示的要多),则可以显示“读取更多”链接:
<?php if ( get_the_content() != get_the_excerpt() ){ ?>

    <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a>

<?php } ?>

关于php - Wordpress显示在条目页脚中阅读更多,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27583109/

10-11 12:30
查看更多