这是我的代码,我默认绑定我的自定义插件(星级)显示在每个帖子下,但是当我从搜索框中搜索这个帖子(苏丹)时,它显示,但我的插件去ruff,不显示星星只是显示
评分:5星4星3星2星1星
代替星号
虽然我检查了页面源我的css和js文件正在加载,但不知道它不工作
image with star在默认页面上工作输入图片描述
带星号的图像不起作用输入图片描述
function wpa_rating_ad($content) {
global $post;
$thePostID = $post->ID;
$star='
<p>
<div class="rating">
<legend>Please rate:</legend>
<input type="radio" id="star5-'.$thePostID.'" name="rating" value="5" data-id="'.$thePostID.'" class="rating-star" />
<label for="star5-'.$thePostID.'" title="Rocks!">5 stars</label>
<input type="radio" id="star4-'.$thePostID.'" name="rating" value="4" data-id="'.$thePostID.'" class="rating-star" />
<label for="star4-'.$thePostID.'" title="Pretty good">4 stars</label>
<input type="radio" id="star3-'.$thePostID.'" name="rating" value="3" data-id="'.$thePostID.'" class="rating-star" />
<label for="star3-'.$thePostID.'" title="Meh">3 stars</label>
<input type="radio" id="star2-'.$thePostID.'" name="rating" value="2" data-id="'.$thePostID.'" class="rating-star" />
<label for="star2-'.$thePostID.'" title="Kinda bad">2 stars</label>
<input type="radio" id="star1-'.$thePostID.'" name="rating" value="1" data-id="'.$thePostID.'" class="rating-star" />
<label for="star1-'.$thePostID.'" title="Sucks big time">1 star</label>
</div>
</p>
<p>
<div id="services-name-'.$thePostID.'" class="services-btn">
</div>
</p>'
;
return $content.$star;
}
add_filter('the_content', 'wpa_rating_ad');
你可以查看wordpress文档,url https://codex.wordpress.org/Plugins