Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

If Textbox Is Filled in, Show This WordPress

  • SOLVED

I have a theme that includes custom theme options. One of those options is for the user to enter their disclaimer. The code for that part of the array looks like this:

array( "name" => "Disclaimer",
"desc" => "Paste codes that belong in the header here. You can put your Google Analytics or other tracking code in this box.",
"id" => $shortname."_disclaimer",
"type" => "textarea",
"std" => ""),


Thus, I can call this text with this code in a page template:

<?php echo stripslashes(get_option('to_disclaimer')); ?>


In a page template for the disclaimer I have a pre-written disclaimer.

<strong>I need a simple PHP if statement to insert in the disclaimer pager template which displays whatever is in the text box IF the text box is filled in. If the text box is not filled in, it displays the disclaimer I have written.

So...

If the text box has writing in it, display that writing.
If the text box has no writing in it, display my text.</strong>

Answers (3)

2014-01-08

Ryan S answers:

@Hariprasad got it but to follow your situation and with corrent IF statement

If the text box has writing in it, display that writing.
If the text box has no writing in it, display my text.


<?php
$disclaimer = stripslashes(get_option('to_disclaimer'));

if( $disclaimer )
echo $disclaimer;
else
echo 'Your custom disclaimer text here';
?>



siouxfan45 comments:

@Ryan S - This code seems to always display the line "Your custom disclaimer text here" - any thoughts?


siouxfan45 comments:

Nevermind, got it.

2014-01-08

Hariprasad Vijayan answers:

Hello,

Try this

$to_ftr_code = stripslashes(get_option('to_ftr_code'))
if(!empty($to_ftr_code))
{
echo $to_ftr_code;
}
else
{
echo 'Custom Text';
}

2014-01-08

Just Me answers:



$to_ftr_code = stripslashes(get_option('to_disclaimer'));