在文章开头添加固定内容
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;
}
}
版权声明:原创作品,未经允许不得转载,否则将追究法律责任。
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:子佩工作室https://zptheme.com/5063.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:子佩工作室https://zptheme.com/5063.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权