180 posts
  • Bought between 1 and 9 items
  • Has been a member for 4-5 years
  • United States
SuperMario290 says

Hello everybody. Okay so in my options page for my WordPress theme I would like to create a checkbox that would be for gravatars. If you check it, they’re shown, if not, then obviously they’re not.

I know how to do regular options, but I have no idea how to do this. Here’s what I’ve got from other resources on the internet but haven’t been able to do this.

array( “name” => “Gravatar”, “desc” => “Check if you would like Gravatars or not”, “id” => $shortname.”_gravatar”, “type” => “checkbox”, “std” => “false”), and then for the index.php i came up with something

<? if get_option(’$spress_gravatar’) { ?> <? echo get_option(’$spress_gravatar_display’); ?> <? } else { ?> <? echo get_option(’$spress_gravatar_no’); ?> <? } ?> I have absoltuely no idea if that’s right but if ANYONE can help me out it would a tremendous help.

385 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 4-5 years
  • United Kingdom
  • Referred between 100 and 199 users
  • Bought between 10 and 49 items
  • Exclusive Author
EugeneO says

The checkbox options save as a string value rather than a boolean as you would expect. So, in the conditional statement in index.php you need to check for the actual “true” or “false” text string.

<?php if ( get_option(‘spress_gravatar’) == ‘true’ ) : ?> Code to show gravatar <?php endif ; ?>

180 posts
  • Bought between 1 and 9 items
  • Has been a member for 4-5 years
  • United States
SuperMario290 says

oh damn sorry i didn’t put that in code tags. but thanks a ton man that helped out a lot!

by
by
by
by
by
by