
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><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill10250" title="Wordpress OAuth"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20e695c2374.jpg" alt="Wordpress OAuth" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill10250" title="Wordpress OAuth" class="overflowclass">Wordpress OAuth</a>
<p class="overflowclass">启动并完成 WordPress.com OAuth 认证,通过 REST API 发布文章。适用于需要生成授权链接、交换授权码等场景。</p>
</div>
<a rel="nofollow" href="/xiazai/skill10250" title="Wordpress OAuth" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>";
$content.= "</div>";
}
return $content;
}
add_filter ('the_content', 'insertFootNote');
以上例子的效果是在每篇文章的尾部自动添加订阅提示。
推荐教程:WordPress教程










