ThemeShaper Forums » Thematic

[closed]

Checkbox in custom theme options

(4 posts)
  • Started 2 years ago by kevinoh
  • Latest reply from kevinoh
  • This topic is not resolved
  1. I have added a custom theme-options page with two text areas and a checkbox. I want to create a function to display one of the textareas only if the check box is checked. I am able to call both textareas and get them to display successfully but for the life of me can't figure out how to do an if/then for the check box.

    Here is what I have been able to get going so far:

    // Add Registration Description from Theme Options page
    function topmarks_reg_description() {	
    
    		if (
    		// THIS IS WHERE I NEED HELP
    		)
    		{
    			// BEGIN GET REGISTRATION DESCRIPTION
    			{ ?>
           			 <div id="reg-description"><p><?php
                		$options = get_option('topmarks_theme_options');
                		echo $options['reg-description'];
            	?> <a href="register">Register now</a></p></div>
       			<?php }
    			// END GET REGISTRATION DESCRIPTION
    		}
    		else
    		{
    			// silence
    		}
    }
    
    // Add our Registration Description function to Thematic Action Hook, number indicates positioning via priority setting
    add_action('thematic_header','topmarks_reg_description', 6);

    Any help with a function if check box is checked?

    Posted 2 years ago #
  2. checkboxes return TRUE if they are checked and FALSE if they are not. so you need to get_option() before the if statement and use its value as the conditional logic.

    Posted 2 years ago #
  3. Okay, makes sense. I am still learning as I go - thanks for sending me in the right direction!

    Posted 2 years ago #
  4. SO i tried this… am i even close?


    // Add Registration Description from Theme Options page
    function topmarks_reg_description() {
    { ?>
    <?php
    $options = get_option('topmarks_theme_options');
    echo $options['show-reg'];
    if ('show-reg' == "true"])
    {
    // BEGIN GET REGISTRATION DESCRIPTION
    { ?>
    <div id="reg-description"><p><?php
    $options = get_option('topmarks_theme_options');
    echo $options['reg-description'];
    ?> Register now</p></div>
    <?php }
    // END GET REGISTRATION DESCRIPTION
    }
    else
    {
    // silence
    }
    }

    // Add our Registration Description function to Thematic Action Hook, number indicates positioning via priority setting
    add_action('thematic_header','topmarks_reg_description', 6);

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.