Sidebar menu to show child pages of parent

Can you advise me on the best way to implement this. I think I’m missing something.

http://dev.bwpjc.org/about-us/

I’ve created a layout using the layout feature and on the sidebar, I only want to show pages that fall under the same parent page. This is currently using a widget.

Is there a looper or condition that will do this job or do I need to add something to the child theme, like

<?php wpb_list_child_pages(); ?>

If so where would I add that?

Thanks

Hello @henrybag,

Thanks for writing to us.

You can list the child pages of the parent page, for that, you can use Looper and set the Looper provider type as “Query String”. Now add this query in the text field.

   post_type=page&post_parent={{dc:post:id}}&posts_per_page=5&orderby=menu_order    

Please have a look at the given screenshot below.

About-The-Tests-Content-Pro

No, add any element like Text or Headline Element to display the page title and add the dynamic content code {{dc:post:title}}

Or

You can set the Looper Provider type as “Current Page Children”
About-The-Tests-Content-Pro

In case if you have not seen the doc of Looper please have a look at it.

Hope it helps
Thanks

Hi

Thanks for getting back to me, however, it’s not quite what I need

So I’ve added the query you suggested and it works fine on the parent page
http://dev.bwpjc.org/about-us/

But if I wanted to show these same links on the child pages so there is navigation around that section is there a way to achieve that?

http://dev.bwpjc.org/about-us/festivals-and-high-holy-day-services/

I have it working using Method 2 on this article but this doesn’t give me all the nice visual editing that pro provides so if there is a way of doing this with a query that would be amazing.

Hi @henrybag,

You can get the Child page of About page on another page by mentioning the ID of the About Page in the Query String given by my colleague. In your case ID of the About page is 109 so the Query String will look like the following.

post_type=page&post_parent=109&posts_per_page=5&orderby=menu_order

Please go through the article on how to find the Page or Post ID: https://theme.co/docs/how-to-locate-post-ids

Hope it helps.
Thanks

OK thanks, but what you have suggested would be specific to the about section and its child pages wouldn’t it?

It was more if there was a way of adding a query that I can put on a Pro > Layout which would then show all the child pages of the parent, regardless of which section you were in. So if I was in the community for instance each of those pages would show all the other children of the parent page.

Hope that makes sense - as I say the code from WPBeginners does the job but it would be great if there was a query that did the same.

Hi @henrybag,

Sorry for the confussion. It has been clear now that you want to show all the child pages of the parent page of the current page.

What you are trying can be done using the Custom option and call a custom function which will return all the child pages of the parent page of the current page.
I have added the following code into my child page functions.php and mentioned the offset in the Looper Provider, and it works fine for me. I would request you to add the following code into your child theme’s functions.php and call the function as mentioned in the screenshot.

add_filter('cs_looper_custom_allchildpage', function($result, $args) 
{    
    global $post;
    echo $post->ID;
    if ( is_page() && $post->post_parent )
    {
        $args = array(
        'order'          => 'ASC',
        'post_parent'    => $post->post_parent,
        'post_status'    => 'published',
        );  
    }
    else
    {
        $args = array(
        'order'          => 'ASC',
        'post_parent'    => $post->ID,
        'post_status'    => 'published',
        );   
    }
    $childpage = get_children( $args );
    return $childpage;
}, 10, 2);

and add a Text element to show the Post Title using the following code.

<a href="{{dc:post:permalink}}">{{dc:post:title"}}</a>

Please find the following screenshot explaining the process.

Test-new-child-Content-Pro (2)

Test-new-child-Content-Pro (4)

NOTE: I have created it in my local environment and it works perfectly fine.

Hope it helps.
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.