在主题的functions.php中添加如下代码:
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 > 200){ //这里是浏览量大于200 $before_content = '<img class="vsystem-neiye-top" style="position: absolute; right: 10px; pointer-events: none;" src="'.B2_CHILD_URI.'/Render/Pic/002.gif" alt="热帖" >'; //图片地址修改成自己的 $lu = $before_content . $content; } else{$lu = $content;}} return $lu; }
在主题的style.css文件中添加如下样式:
.vsystem-neiye-top{ top: -35px; width: 106px; }
上传如下图片,并在图片引入地址重新填写你上传的图片地址,即可。