Last active
December 17, 2015 20:59
-
-
Save josephhinson/5671163 to your computer and use it in GitHub Desktop.
So, you want to pull content from one page into another...maybe you have an "upcoming events" section that you want to be its own page, yet you also want to show on another page. This shortcode will help you do that. Put this code in your functions.php file.
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
| <?php | |
| // [page name="contact"] | |
| function page_content($atts) { | |
| extract(shortcode_atts(array( | |
| 'name' => '' | |
| ), $atts)); | |
| $return = ''; | |
| $args=array( | |
| 'name' => $name, | |
| 'post_type' => 'page', | |
| 'post_status' => 'publish', | |
| 'numberposts' => 1 | |
| ); | |
| $thepages = get_posts($args); | |
| foreach ($thepages as $thepage) { | |
| $return .= apply_filters('the_content',$thepage->post_content); | |
| } | |
| return $return; | |
| } | |
| add_shortcode("page", "page_content"); | |
| // end shortcode | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment