I would like to get show multiple page’s content on one page with shortcodes. If I use return $html;
the shortcodes not working, if I use return do_shortcode($html);
the shortcode working, but the content of the page dissapear. What is the working solution?
function get_page_func( $atts ){
extract(shortcode_atts( array(
'title' => ''
), $atts ) );
$page = get_page_by_title($title);
$args = array(
'include' => $page->ID,
);
$pages = get_pages($args);
$html = $pages[0]->post_content;
return do_shortcode($html);
}
add_shortcode( 'get_page', 'get_page_func' );
Use above code. Wherever you require shortcode to be executed just use the following line
echo do_shortcode(‘get_page’);
This will work for PHP page and also work if you use a shortcode in post or page created using dashboard.
I had the same problem and code below solved it.
It doesn’t work: