Skip to content

Instantly share code, notes, and snippets.

@brandonhimpfen
Created May 28, 2014 18:34
Show Gist options
  • Save brandonhimpfen/26c534ddf8a146c238af to your computer and use it in GitHub Desktop.
Save brandonhimpfen/26c534ddf8a146c238af to your computer and use it in GitHub Desktop.
Display the content of one page in another page.
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' );
@brandonhimpfen
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment