Created
May 28, 2014 18:34
-
-
Save brandonhimpfen/26c534ddf8a146c238af to your computer and use it in GitHub Desktop.
Display the content of one page in another page.
This file contains hidden or 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 get_post_page_content( $atts ) { | |
extract( shortcode_atts( array( | |
'id' => null, | |
'title' => false, | |
), $atts ) ); | |
$the_query = new WP_Query( 'page_id='.$id ); | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
if($title == true){ | |
the_title(); | |
} | |
the_content(); | |
} | |
wp_reset_postdata(); | |
} | |
add_shortcode( 'get_content', 'get_post_page_content' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The shortcode is:
[get_content id="" title= /]
Where id is the id of the page. The id of the page goes inside the quotes. The id must be set.
title is false by default. Set the value of title to true, if you want the title of the page you are including to show.