Have used a code sample from internet to make a shortcode to return a certain page. However the shortcode does not seem to be rendering but shows the shortcode text as it. The function has been defined inside functions.php
.
The code is as follows:
/* Code taken from:
* http://alex.leonard.ie/2010/09/09/wordpress-shortcode-to-insert-content-of-another-page/
*/
function pa_insertPage($atts, $content = null) {
// Default output if no pageid given
$output = NULL;
// extract atts and assign to array
extract(shortcode_atts(array(
"page" => '' // default value could be placed here
), $atts));
// if a page id is specified, then run query
if (!empty($page)) {
$pageContent = new WP_query();
$pageContent->query(array('page_id' => $page));
while ($pageContent->have_posts()) : $pageContent->the_post();
// assign the content to $output
$output = get_the_content();
endwhile;
}
return $output;
}
add_shortcode('insert_page', 'pa_insertPage');
thank you for the help.. the shortcode seems to be rendering now (the issue was likely the wrong function.php file :) ) ..
It seems that the Theme had another functions.php file which was to be used.. (not sure if the theme made a duplicate copy or was mistakenly done by a developer .. :) ) ..
regards