Last active
December 16, 2015 10:29
-
-
Save solepixel/5420676 to your computer and use it in GitHub Desktop.
WordPress shortcode to get a page's content
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 | |
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