Hello, I would like to display specific pages in the left sidebar of my page which is working. in the right sidebar I would like to display only the sub pages of the current page. Is this possible?
If you add the following filter to your active theme’s function.php file the menu will display the current page’s children only.
If you wish to also include the current page you may use the “Display highest level parent page” option. Leaving this option unchecked will not display the current page.
It’s a bit tricky to determine the ids because this is an Elementor widget, but give the following a try:
Let me know if it doesn’t work and I’ll spin up an environment with Elementor loaded to see if there is anything unique we can use to target the widget.
Give this version a try which checks if the current item is a first level child and if has no children does not use it’s parent as the the top level menu item:
Hi Frank,
If you add the following filter to your active theme’s function.php file the menu will display the current page’s children only.
If you wish to also include the current page you may use the “Display highest level parent page” option. Leaving this option unchecked will not display the current page.
Have a great day!
Hi, thank you very much, this is great.
But I would like to keep the “normal” menu in the left sidebar and show only the submenu items in right sidebar.
Is this possible somehow?
Thanks again, Frank
Hi Frank,
You may target a specific sidebar or widget id by changing the filter to the following:
SIDEBAR_ID_GOES_HERE
to the id of the sidebar.WIDGET_ID_GOES_HERE
to the id of the widget.id
).Hi, thanks again.
I have sended credentials so if you could take a look it would be great.
Frank
Hi Frank,
It’s a bit tricky to determine the ids because this is an Elementor widget, but give the following a try:
Let me know if it doesn’t work and I’ll spin up an environment with Elementor loaded to see if there is anything unique we can use to target the widget.
Hi, this worked partially.
When I open a page including a parent item it is working fine and show only the child items within the left sidebar.
When I open a subpage the child items are gone.
You might want to look here
https://www.viacarta.eu/horoskope/50-plus-horoskop/
and here
https://www.viacarta.eu/horoskope/50-plus-horoskop/50-plus-horoskop-widder/
Thanks, Frank
Hi Frank,
Do the sub pages have children?
The filter as written will only show child pages of the current page. If you are on a page which does not have children, there is nothing to display.
No, there are no children on subpages so I was hoping the code will reference to the parent item of the current subpage.
Hi Frank,
A little creative engineering and the filter can be made to display the current page’s level when the current page has no children:
You are great!!! It is working. 🙂
Thank you so much for this outstanding support.
Frank
Hi, There is only one thing I would like to ask.
If a parent page got no child pages the entire menu is displayed.
Can this be changed somehow that in this case none of any menu item is shown in right sidebar?
Thanks, Frank
Hi Frank,
Can you give me an example of a parent page with no children that has a menu displayed?
Hi,
Sure: https://www.viacarta.eu/horoskope/esshoroskop/
Thanks!
Hi Frank,
Give this version a try which checks if the current item is a first level child and if has no children does not use it’s parent as the the top level menu item:
Have a great day!
Awesome 🙂
Thank you so much.
Frank