WordPress : Shortcode to insert content of another page by ID

/* * Shortcode to insert content of another page (ID) */ function pa_insertPage($atts, $content = null) { $output = NULL; // default value could be placed between '' extract(shortcode_atts(array("page" => ''), $atts)); if (!empty($page)) { $pageContent = new WP_query(); $pageContent->query(array('page_id' => $page)); while ($pageContent->have_posts()) : $pageContent->the_post(); $output = apply_filters( 'the_content', get_the_content() ); endwhile; } return $output; } add_shortcode('pa_insert', 'pa_insertPage');
WordPress Shortcode to insert content of another page (by ID). Code based on Alex Leonard's ( http://goo.gl/dXeoGF)

[pa_insert page="#"]
// Shortcode - where # = the page id

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.