Skip to content

Instantly share code, notes, and snippets.

@solepixel
Last active December 16, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solepixel/5420676 to your computer and use it in GitHub Desktop.
Save solepixel/5420676 to your computer and use it in GitHub Desktop.
WordPress shortcode to get a page's content
<?php
add_shortcode('get-page', 'mytheme_get_page');
function mytheme_get_page($atts=array(), $content=NULL){
extract(shortcode_atts(array(
'page' => NULL
), $atts));
if(!$page){
return '';
}
if(!is_numeric($page)){
$obj = get_page_by_path($page);
if ($obj) {
$page = $obj->ID;
} else {
return '';
}
}
$include = get_page($page);
return apply_filters('the_content', $include->post_content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment