Support » Fixing WordPress » Only display theme option if entry is present?
4 years, 9 months ago
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:
$options = get_option('option_name');
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)) : ?>
But I don’t know how to get this to work with the theme options call.
Can anyone help please?
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.