0

需要帮助,我不知道我的代码有什么问题,因为它重复了“你已经投票了!” 它在页眉和页脚中遍布整个网站。它应该只在内容中。

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; 
        }
    }
 }
4

0 回答 0