Created
September 26, 2012 06:25
-
-
Save onishiweb/3786419 to your computer and use it in GitHub Desktop.
WordPress post meta if statement
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 | |
// Perform the get meta inside the condition of the if statement, | |
// it will return true if there's a value, false if not, | |
// and if true the $meta variable will be set to the meta value | |
if( $meta = get_post_meta($post_id, 'meta_name', true) ): | |
echo $meta; | |
else: | |
// Do something else | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment