WordPress.org

Ready to get started?Download WordPress

Forums

Creating Default Text for Custom Theme Options (2 posts)

  1. wphax
    Member
    Posted 3 years ago #

    This is kinda urgent if someone could help me out ASAP, that would be majorly AWESOME!

    Basically, I used the default template found in the codex section titled Creating Options Pages (http://codex.wordpress.org/Creating_Options_Pages), and it works fine and dandy, but currently it doesn't have some sort of a default text for the fields. For example, here is my code on the homepage:

    <div id="header">
        	<h1 class="center font-georgia">
    			<?php echo get_option('headline_one'); ?>
            </h1>
        </div>

    I know somehow I could just use a code to check if headline_one has any content, and if it doesn't, display this text. Else if it does, display the headline_one text.

    I just can't do this myself, not much of a PHP coder, I can just copy and paste codes to make them work so if someone could whip up that code for me quick that would be great and I would appreciate it very much.

    Thanks in advance!

  2. wphax
    Member
    Posted 3 years ago #

    Actually, I fixed this myself. This is the code I used for reference if anyone else might need it:

    <?php
            	$headline_one = get_option('headline_one');
    
    			if($headline_one == "") {
    				echo "<h1 class=\"center font-georgia\">This is the default text for the first headline and you can't change that. Well actually, you can in the options panel now! Weeeeeeeee!</h1>";
    			} elseif($headline_one != "") {
    				echo "<h1 class=\"center font-georgia\">" . get_option('headline_one') . "</h1>";
    			}
    		?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.