What’s the code you used to include the buttons?
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.
I’m afraid that’s not possible. The plugin does not output anything by default. So you’ve had to put some code somewhere π
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.)
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.
What’s that extra . for on the “$content .= thumbs_rating_getlink(); ” line? Can’t remember ever seeing something like that before.
Because that code block just hosed the whole site.
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’);
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.
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();
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.