Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ricard Torres

    (@quicoto)

    What’s the code you used to include the buttons?

    Thread Starter ubergeeke

    (@ubergeeke)

    I didn’t. I only installed the plugin but made no code mods except for Custom CSS to remove down-vote, as directed by you last week.

    Plugin Author Ricard Torres

    (@quicoto)

    I’m afraid that’s not possible. The plugin does not output anything by default. So you’ve had to put some code somewhere ??

    Thread Starter ubergeeke

    (@ubergeeke)

    Ah, right! Just reviewed the installation instructions.

    Ok, I added this code block to the end of functions.php:

    function thumbs_rating_print($content)
    {
    return $content.thumbs_rating_getlink();
    }
    add_filter(‘the_content’, ‘thumbs_rating_print’);

    Other than that, I added this code block to my themes Custom CSS section, both to change the color AND to get rid of the thumbs down (I only want users to vote up, not down):

    .thumbs-rating-down{
    display: none !important;
    }

    .thumbs-rating-container .thumbs-rating-up {
    background: #CC181E!important;
    }

    OVERALL GOAL: for only logged in users to up-vote posts. (Not pages, not any other kind of content, just posts; and only logged-in users.)

    Plugin Author Ricard Torres

    (@quicoto)

    Hi,

    You should use Conditional Tags.

    The code in your functions.php should look something like:

    function thumbs_rating_print($content)
    {
    
    	if ( is_single() && is_user_logged_in() ){
    
    		$content .= thumbs_rating_getlink();
    	}
    
        return $content
    }
    add_filter('the_content', 'thumbs_rating_print');

    Let me know how it goes.

    Thread Starter ubergeeke

    (@ubergeeke)

    What’s that extra . for on the “$content .= thumbs_rating_getlink(); ” line? Can’t remember ever seeing something like that before.

    Thread Starter ubergeeke

    (@ubergeeke)

    Because that code block just hosed the whole site.

    Thread Starter ubergeeke

    (@ubergeeke)

    Reverted back to this, which restored site to previous state.

    function thumbs_rating_print($content)
    {
    return $content.thumbs_rating_getlink();
    }
    add_filter(‘the_content’, ‘thumbs_rating_print’);

    Plugin Author Ricard Torres

    (@quicoto)

    Odd, let’s try again:

    function thumbs_rating_print($content)
    {
    
    	if ( is_single() && is_user_logged_in() ){
    
    		$content = $content . thumbs_rating_getlink();
    	}
    
        return $content;
    }
    add_filter('the_content', 'thumbs_rating_print');

    If you see any errors when applying this, post them here.

    Cheers.

    Thread Starter ubergeeke

    (@ubergeeke)

    I added the code This time, I got no errors, and no upvote button when not logged in. Success!

    Then I logged in, and I *still* can’t see the upvote button, so it’s not working. Suggestions? Should I remove the spaces around the period in the following line and see if that works?

    $content = $content . thumbs_rating_getlink();

    Plugin Author Ricard Torres

    (@quicoto)

    No that has nothing to do.

    I don’t know what else to do. The condition it’s fairly simple:

    When any single Post (or attachment, or custom Post Type) page is being displayed and if any user is currently logged-in.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘"Disable on pages" not working’ is closed to new replies.