WordPress.org

Ready to get started?Download WordPress

Forums

Only display theme option if entry is present? (2 posts)

  1. flint_and_tinder
    Member
    Posted 2 years ago #

    Hi all,

    I am currently using the brilliant NHP theme framework, but I'd like to add the functionality to only display an element if a certain theme option field has data entered into it.

    According to the wiki, the theme options can be displayed using the following methods:

    <?php
    $options = get_option('option_name');
    ?>

    or

    <?php
    echo $options['unique_id'];
    ?>

    Previously with custom fields I have used this to achieve what I want:

    <?php $blah1 = get_post_meta($post->ID, 'blah_blah_blah', true);
    if (!empty($blah1)) : ?>

    etc. etc.

    But I don't know how to get this to work with the theme options call.

    Can anyone help please?

    Many thanks.

    Adam.

  2. luckdragon
    Member
    Posted 2 years ago #

    what are you trying to do? I mean, if you're doing

    <?
    $this = get_option('option_name');
    if ($this) :
    ?>
    put html to display here
    <? endif; ?>

    that will only display the text if the option actually returns a result, if it doesn't, then $this would be equivalent to "" or null, so it'll be ignored.

Topic Closed

This topic has been closed to new replies.

About this Topic