Created
October 5, 2012 16:49
-
-
Save scottnix/3840934 to your computer and use it in GitHub Desktop.
Example of adding a shortcode using custom fields "custom-gallery"
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
function snix_childtheme_gallery() { | |
global $post; | |
// display this only on pages | |
if (is_page()) { | |
// get the correct custom field data | |
$custom_gallery = get_post_meta($post->ID, 'custom-gallery', true); | |
// if custom field is available, do this | |
if ($custom_gallery) { | |
// do_shortcode is needed | |
$galleryoutput = do_shortcode( $custom_gallery ) ; | |
// put it on the screen | |
print $galleryoutput; | |
// if no custom field, do nothing | |
} else { | |
// silence | |
} | |
} | |
} | |
// then we will hook this on "thematic_abovecontainer", but the hook can be moved anywhere. | |
add_action('thematic_abovecontainer', 'snix_childtheme_gallery'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment