本文最后更新于 2022-10-14,已超过 365 天未更新,内容可能已失效。
在文章开头添加固定内容
add_filter('the_content', 'add_zm_content_beforde');
function add_zm_content_beforde( $content ) {
if( !is_feed() && !is_home() && is_singular() && is_main_query() ) {
$before_content = '在文章内容开头添加固定内容';
$zm = $before_content . $content;
}
return $zm;
}
在文章末添加固定内容
add_filter('the_content', 'add_zm_content_after');
function add_zm_content_after( $content ) {
if( !is_feed() && !is_home() && is_singular() && is_main_query() ) {
$after_content = '在文章内容末尾添加固定内容';
$zm = $content . $after_content;
}
return $zm;
}
同时添加
add_filter('the_content', 'add_zm_content_before_and_after');
function add_zm_content_before_and_after( $content ) {
if( !is_feed() && !is_home() && is_singular() && is_main_query() ) {
$after_content = '在文章内容末尾添加固定内容';
$before_content = '在文章内容开头添加固定内容';
$zm = $before_content . $content . $after_content;
}
return $zm;
}
指定添加
add_filter('the_content', 'add_zm_content_after_mac_custom_post_type');
function add_zm_content_after_mac_custom_post_type( $content ) {
if (is_singular( "mac" )){
$new_mac_content = '只在自定义帖子类型“mac”文章末尾添加固定内容';
$aftercontent = $new_mac_content;
$zm = $content . $aftercontent;
return $zm;
} else {
return $content;
}
}
除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。
![解决nginx: [emerg] mkdir() “/dev/shm/nginx-cache/wp” 的问题](https://oss.zptheme.com/wp-content/uploads/2023/06/1687188094-df5b941552926d5.png)




登录后即可发表评论
全部评论 (70)
成功的法则极为简单,但简单并不代表容易。
挫折经历的太少,所以总是把一些琐碎的小事看的太重。
人生没有绝对精彩,雨后或许没有彩虹,但后退一步确是失败。
嘴里说的人生,就是自己以后的人生。
一个人只有投身于伟大的时代洪流中,他的生命才会闪耀出光彩。
一切真实的感知,都是由汗水和泪水换来的。
人生最精彩的不是实现梦想的一瞬间,而是坚持梦想的过程。
老要靠别人的鼓励才去奋斗的人不算强者;
励志是给人快乐,激励是给人痛苦。
与其用泪水悔恨昨天,不如用汗水拼搏明天。
有的人生来就不需要任何原谅,因为他们不论有多少次机会都没点改进。
跟别人比,会使得自己永远都不快乐。跟自己比,看到自己每天都在进步,你会很快乐。
改变自己,是自救,影响别人,是救人。
每一枝玫瑰都有刺正如每个人的性格里都有你不能容忍的部分。
人生路上什么都不怕,就怕自己投降。
没有了理想,青春之花也便凋谢了。
一生中你唯一需要回头的时候,是为了看自己到底走了多远。
认定了的路,再痛也不要皱一下眉头,你要知道,再怎么难走都是你自己选的,你没有资格喊疼。
即使爬到最高的山上,一次也只能脚踏实地地迈一步。
当你付出的劳动没有得到金钱和物质上的回报时,一定可以得到等值的精神愉悦。