Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ?>

I think $content = apply_filters('the_content', $content); is basically stripping out part of the content

Any idea why the shortcode isn't showing?

share|improve this question
hmm, ok, just updated –  rob.m Jan 28 '13 at 17:51

2 Answers 2

I would like to suggest you to use WP_Query to fetch pages from db:

$the_query = new WP_Query( array( 
    'post_parent'    => $page->ID,
    'orderby'        => 'menu_order',
    'order'          => 'ASC',
    'posts_per_page' => 3,
) );

while ( $the_query->have_posts() ) :

    <div class="span4">
        <h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
        <?php the_content() ?>


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 the foreach loop at the 2nd line of your snippet.

share|improve this answer
Thanks but the content isn't showing up, only the titles. This is the full code I am using: Baically I have "Home" with 3 categories and each category has childs. I need to be able to show each category title and each child tilte and content. Finally limit the childs to be 3 per category. I am styling each category in a row. By using that full code in pastebin, which uses yours, I am only displaying the category titles and nothing more. –  rob.m Jan 28 '13 at 18:34
up vote 1 down vote accepted

This is how i resolved it:

 Template Name: home
 get_header(); ?>

<?php $counter = 1 ?>
 <div class="row-fluid"> 
    $args = array(
'child_of' => 4,
'parent' => 0,
'post_type' => 'page',
'post_status' => 'publish'
 $childrens = query_posts('showposts=3&post_parent=4&post_type=page&orderby=menu_order&order=DESC');

 foreach ( $childrens as $children ) :
if ( have_posts ) :
    while ( have_posts() ) : the_post();
        <div class="span4">
                <?php the_title(); ?>
            <?php the_content(); ?>
<? if ($counter % 3 == 0): ?>
<div id="content" class="row-fluid"></div>
<div class="row-fluid">
    <?php endif; ?>
<?php $counter++; ?>

<?php get_footer(); ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.