Hi,
Trying to get a page to appear below a normal page via shortcode - code below works for inserting a 'page' below a 'page' but how would I alter the code to intsert a 'custom post typ' below a page. Anybody any ideas?
Here's the code I'm trying to alter:
/**
* Create a shortcode to insert content of a page of specified ID
*
* @param array attributes of shortcode
* @return string $output Content of page specified, if no page id specified output = null
*/
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('pa_insert', 'pa_insertPage');
[Moderator Note: Please post code & markup between backticks (not single quotes) or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]