Html 在Wordpress中的每篇文章后添加分隔符
我需要使用图像来分隔我的文章(帖子)。我在下面找到了这个函数Html 在Wordpress中的每篇文章后添加分隔符,html,css,wordpress,Html,Css,Wordpress,我需要使用图像来分隔我的文章(帖子)。我在下面找到了这个函数 function funny_cat_filter( $content ) { $content .= '<img src="(image url)"/>'; return $content; } add_filter( 'the_content', 'funny_cat_filter' ); 功能有趣的猫过滤器($content){ $content.=''; 返回$content; } 添加过滤器(“内容”、“有趣
function funny_cat_filter( $content ) {
$content .= '<img src="(image url)"/>';
return $content;
}
add_filter( 'the_content', 'funny_cat_filter' );
功能有趣的猫过滤器($content){
$content.='';
返回$content;
}
添加过滤器(“内容”、“有趣的过滤器”);
不要介意函数名。这很好,但有一点烦人的细节。它也会在页面上添加图像,我不希望这样。我想这只是在每一篇文章后,而不是在每一页上添加
我该怎么做 您可以查看您是在与的帖子中,还是在与的家中
功能有趣的猫过滤器($content){
if(is_single()| | is_home())
$content.='';
返回$content;
}
添加过滤器(“内容”、“有趣的过滤器”);
嘿,这是我想做的另一件事。这在页面上删除了它,但也在主页上删除了它(在主页上可以看到所有帖子),并且只将其添加到单个帖子页面。我希望它能显示在主页上,把文章的摘录分开。谢谢。@user3088451如果您想在家中使用它,请添加is\u home()
。我编辑了我的答案。
function funny_cat_filter( $content ) {
if (is_single() || is_home())
$content .= '<img src="(image url)"/>';
return $content;
}
add_filter( 'the_content', 'funny_cat_filter' );