Parent-Child Theme Page Again

Support Area Forums Foundation Parent-Child Theme Page Again

Viewing 2 posts - 1 through 2 (of 2 total)
URL to the page in question:
  • Author
    Posts
  • #10862
    ancd
    Participant

    Bill,

    Hi again. Where can we add the following code to display child pages on parent page, in our case: “News” with post ID->11:

    $post->ID,
    ‘post_type’ => ‘page’
    );
    $subpages = new WP_query($args);

    // create output
    if ($subpages->have_posts()) :
    $output = ‘

    ‘;
    else :
    $output = ‘

    No subpages found.

    ‘;
    endif;

    // reset the query
    wp_reset_postdata();

    // return something
    return $output;
    }

    // turn the function into a shortcode
    add_shortcode(‘subpage_peek’, ‘subpage_peek’);

    ?>

    It’s has worked perfectly for others and not sure why it doesn’t work on our site. We’ve tried the code on page.php and page-full.php but no luck. We’ve tried various available parent-children codes on wordpress.org but still no success. We tried on function.php but it was “fatal” but luckily got the site back.

    Need your help.

    #10863
    Bill Robbins
    Moderator

    It looks like that function is attempting to add a shortcode to display child pages. There’s a plugin called Child Pages Shortcode that indicates it will do that too for you.

    You can also modify the theme so you can run a shortcode inside a widget. To do that, edit the functions.php file and place this at the bottom:

    
    add_filter( 'widget_text', 'shortcode_unautop');
    add_filter( 'widget_text', 'do_shortcode');
    

    After you save your changes, you could then create a text widget and place the shortcode for the plugin in the widget. That would cause the child pages to be displayed.

    I haven’t tried the plugin, but it’s a worth a shot.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Parent-Child Theme Page Again’ is closed to new replies.