需要帮助,我不知道我的代码有什么问题,因为它重复了“您已经投票!”它在整个页眉和页脚中都有该站点。它应该仅在内容中。
add_filter('the_content','my_the_content_filter');
function my_the_content_filter($content) {
// return $content;
$user_id = get_current_user_id();
$is_voted = get_user_meta($user_id,'is_voted', true);
if(is_page('online-voting')){
if($is_voted == 1){
echo '<div class="alert alert-success vote-success" role="alert">';
echo 'You have already voted!';
echo '</div>';
}else{
return $content;
}
}
}