CMS教程 · 2024年11月25日

wordpress怎么自动在正文内容后添加内容

wordpress怎么自动在正文内容后添加内容插图

怎么自动在正文内容后添加内容    

很多时候,你都需要在文章内容后面添加一些信息,例如订阅,文章分享,收藏和Creative Commons协议声明等。 

要在文章尾部自动添加内容的话,只需要在主题的function.php里添加一下代码: 

function insertFootNote($content) { 
    if(!is_feed() && !is_home()) { 
        $content.= "<div>"; 
        $content.= "<h4>Enjoyed this article?</h4>"; 
        $content.= "<p>Subscribe to our <a>RSS feed</a> and never miss a recipe!</p>"; 
        $content.= "</div>"; 
    } 
    return $content; 
} 
add_filter ('the_content', 'insertFootNote');

登录后复制

以上例子的效果是在每篇文章的尾部自动添加订阅提示。

推荐教程:

以上就是怎么自动在正文内容后添加内容的详细内容,更多请关注米云其它相关文章!