我们有一个盒子div,需要将它添加到内容的顶部或底部,
所以我们如何在add_filter中使用这个循环(' the_content',' box div');
这是我们的循环
if (is_array($my_box_pos)) {
foreach ($my_box_pos as $key => $val) {
if ( $val[moz]=="bottom" || $val[moz]=="top_and_bottom" )
sandy_box($bottom);
}
}
这是内容过滤器
function content_sample($content) {
if( is_singular() && is_main_query() ) {
$new_content = '<p>This is added to the bottom of all post and page content, as well as custom post types.</p>';
$content .= $new_content;
}
return $content;
}
add_filter('the_content', 'content_sample');
有人可以帮帮我吗?
答案 0 :(得分:0)
function content_sample($content) {
if( is_singular() && is_main_query() ) {
$new_content = '<p>This is added to the bottom of all post and page content, as well as custom post types.</p>';
if (is_array($my_box_pos)) {
foreach ($my_box_pos as $key => $val) {
if ( $val[moz]=="bottom" || $val[moz]=="top_and_bottom" )
$content .= $new_content;
}
else { $content = $new_content . $content; }
}
}
return $content;
}
add_filter('the_content', 'content_sample');
试试这个,我不确定它是否适合你。