I am using the folowing to get child title and content. Each child has a gallery and a short code in the content editor in the content, but I only get the gallery and not shortcode. It isn’t something to do with the short code but rather on the content as I tried to add some paragraph to the content after the gallery and it does not show up.
<?php $pages = get_pages('child_of='.$page->ID.'&sort_order=asc&number=3&sort_column=menu_order&parent='.$page->ID);
foreach($pages as $page) {
$content = $page->post_content;
$content = apply_filters('the_content', $content);
?>
<div class="span4">
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<?php echo $content ?>
</div>
I think $content = apply_filters('the_content', $content);
is basically stripping out part of the content
Any idea why the shortcode isn’t showing?
I would like to suggest you to use
WP_Query
to fetch pages from db:Also be careful! You use
$page
variable at first line of your snippet as already defined, and then you re declare it again when you use it in theforeach
loop at the 2nd line of your snippet.This is how i resolved it: