![图片[1]-文章阅读量达到一定数量页面出现自定义热帖图标-精品资源网](https://www.jpzyw.net/wp-content/uploads/2024/02/002.gif)
文章阅读量达到一定数量页面出现自定义热帖图标,图标可以自由替换为自己想要的图片,非常适合子比主题,兼容黑夜模式,效果不错哦,喜欢的朋友可以试试!
/*文章开头大于50浏览量出现热帖图片*/
add_filter('the_content', 'add_lu_content_beforde');
function add_lu_content_beforde( $content ) {
if( !is_feed() && !is_home() && is_singular() && is_main_query() ) {
$viewnum= (int) get_post_meta( get_the_ID(), 'views', true );
if ($viewnum > 50){ //这里是浏览量大于50
$before_content = '<img style="position: absolute; right: 10px; pointer-events: none; z-index: 10;" src="https://www.xbwx.cc/wp-content/themes/zibll/img/rt002.gif" alt="热帖" >'; //图片地址修改成自己的
$lu = $before_content . $content;
}
else{$lu = $content;}}
return $lu;
}
/*文章开头大于100浏览量出现热帖图片12.23修改*/
add_filter('the_content', 'add_lu_content_beforde');
function add_lu_content_beforde( $content ) {
if( !is_feed() && !is_home() && is_singular() && is_main_query() ) {
$viewnum = (int) get_post_meta( get_the_ID(), 'views', true );
if ($viewnum > 100) { //这里是浏览量大于100
$before_content = '<img style="position: absolute; right: 10px; pointer-events: none; z-index: 10;" src="https://www.xbwx.cc/wp-content/themes/zibll/img/rt002.gif" alt="热帖" >'; //图片地址修改成自己的
$lu = $before_content . $content;
} else {
$lu = $content;
}
} else {
$lu = $content;
}
return $lu;
}
© 版权声明
THE END
暂无评论内容