180 posts
  • Has been part of the Envato Community for over 4 years
  • Has collected 1+ items on Envato Market
  • Located in 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.

390 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
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
  • Has been part of the Envato Community for over 4 years
  • Has collected 1+ items on Envato Market
  • Located in 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