I defined a variable called $thumbs_number.
I did var_dump:
string(52) "2"
and print_r
2
It looks like $thumbs_number is 2 right now.
But then I do this:
<?php if ( $thumbs_number == 2 ) : ?>
<span><?php _e( 'two likes' ); ?></span>
<?php else : ?>
<span><?php _e( 'likes' ); ?></span>
<?php endif; ?>
I’m still getting ‘likes’ not ‘two likes’
What I’m doing wrong?
EDIT:
here is the variable comming from:
<?php $thumbs_number = wp_gdsr_render_article_thumbs($template_id = 46, $read_only = false, $stars_set = "", $stars_size = 0, $stars_set_ie6 = "", $echo = false); ?
http://plugins.svn.wordpress.org/gd-star-rating/tags/1.9.9/code/fn/legacy.php says “@return string html with rendered contents” in the docs. It is probably not just returning the number, or whitespace along with it, but html-tags (you can check this by using ‘view source’ on the output result. If you just view it in the browser, it will parse the html-tags and you won’t see them.)
A simple trim isn’t enough. (Besides, php can autoconvert the string with spaces to a number.) Either check for a more appropriate wordpress function that gives it back number you want without html, or use a regexp / substring to extract the number.