Created
July 16, 2014 01:58
-
-
Save michaelbrazell/25c8c8b18afb6aaabade to your computer and use it in GitHub Desktop.
Using a conditional for a custom field in a Wordpress theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Assign the custom field to a variable | |
$her_final_word = get_post_meta($post->ID, 'her_final_word', true); | |
// Check if variable is not empty | |
if($her_final_word !='') { | |
// True: Print the variable | |
?><p><?php echo $her_final_word; ?></p><?php | |
} | |
else { | |
// Default text that will appear | |
?><p>No Final Word Yet</p><?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment