<title>
Comments on: How to get submenu items from a WordPress menu based on parent or sibling </title>
<atom:link href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/feed/" rel="self" type="application/rss+xml"/>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/</link>
<description/>
<lastBuildDate>Mon, 08 Feb 2021 02:00:26 +0000</lastBuildDate>
<sy:updatePeriod>
hourly </sy:updatePeriod>
<sy:updateFrequency>
1 </sy:updateFrequency>
<generator>https://wordpress.org/?v=6.6.2</generator>
<item>
<title>
By: Hitesh Patel </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-770</link>
<dc:creator>
<![CDATA[ Hitesh Patel ]]>
...</dc:creator>
<pubDate>Mon, 08 Feb 2021 02:00:26 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-770</guid>
<description>
<![CDATA[ It is very good and working fine with all options but in my side not working on my single.php any solution? ]]>
...</description>
<content:encoded>
<![CDATA[ <p>It is very good and working fine with all options but in my side not working on my single.php any solution?</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Darek Podbereski </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-758</link>
<dc:creator>
<![CDATA[ Darek Podbereski ]]>
...</dc:creator>
<pubDate>Sun, 01 Dec 2019 22:05:20 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-758</guid>
<description>
<![CDATA[ In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-753">Peter Westerlund</a>.
Anyone know how to fix this problem ? @Christian Varga can you please help with this problem ? Solution seems to work as expected, but only one main page it simply trow errors. ]]>
...</description>
<content:encoded>
<![CDATA[ <p>In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-753">Peter Westerlund</a>.</p>
<p>Anyone know how to fix this problem ? @Christian Varga can you please help with this problem ? Solution seems to work as expected, but only one main page it simply trow errors.</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Peter Westerlund </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-753</link>
<dc:creator>
<![CDATA[ Peter Westerlund ]]>
...</dc:creator>
<pubDate>Wed, 15 May 2019 14:50:28 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-753</guid>
<description>
<![CDATA[ I just gets an infinite loop. What could be the problem? ]]>
...</description>
<content:encoded>
<![CDATA[ <p>I just gets an infinite loop. What could be the problem?</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Marco Rx </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-752</link>
<dc:creator>
...</dc:creator>
<pubDate>Thu, 09 May 2019 20:45:40 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-752</guid>
<description>
<![CDATA[ Hello,
imagine that page B also has a child page, let's say B1.
How can I still show the menu and the sub-menu on this third level page. Note that B1 is not part of any sub-menu, I get there trough a direct link on page B.
Thanks ]]>
...</description>
<content:encoded>
<![CDATA[ <p>Hello,<br />
imagine that page B also has a child page, let’s say B1.<br />
How can I still show the menu and the sub-menu on this third level page. Note that B1 is not part of any sub-menu, I get there trough a direct link on page B.<br />
Thanks</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Christian Schlender </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-748</link>
<dc:creator>
<![CDATA[ Christian Schlender ]]>
...</dc:creator>
<pubDate>Thu, 20 Sep 2018 14:33:15 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-748</guid>
<description>
<![CDATA[ In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-747">Christian Varga</a>.
Works perfect, thank you very much :-) ]]>
...</description>
<content:encoded>
<![CDATA[ <p>In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-747">Christian Varga</a>.</p>
<p>Works perfect, thank you very much 🙂</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Christian Varga </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-747</link>
<dc:creator>
<![CDATA[ Christian Varga ]]>
...</dc:creator>
<pubDate>Sat, 08 Sep 2018 02:11:11 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-747</guid>
<description>
<![CDATA[ In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-746">Christian Schlender</a>.
Hey Christian, you'll want to prevent the hook from dropping any root-level menu items. This can be done on like 43; simply change the condition to
<code>! empty( $item->menu_item_parent )</code>
I've created a gist for you here: https://gist.github.com/levymetal/c5cde99d888982205ebed75288618d80 ]]>
...</description>
<content:encoded>
<![CDATA[ <p>In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-746">Christian Schlender</a>.</p>
<p>Hey Christian, you’ll want to prevent the hook from dropping any root-level menu items. This can be done on like 43; simply change the condition to </p>
<p><code>! empty( $item->menu_item_parent )</code></p>
<p>I’ve created a gist for you here: <a href="https://gist.github.com/levymetal/c5cde99d888982205ebed75288618d80" rel="nofollow ugc">https://gist.github.com/levymetal/c5cde99d888982205ebed75288618d80</a></p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Christian Schlender </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-746</link>
<dc:creator>
<![CDATA[ Christian Schlender ]]>
...</dc:creator>
<pubDate>Wed, 05 Sep 2018 22:19:13 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-746</guid>
<description>
<![CDATA[ I would also like to show the other pages on first level, how can I do that? That means when Im on page B the menu should look like:
– A
– – B
– – C
– D
The same when Im on page C or on page A.
But if Im on page D the menu should look like:
– A
– D
That means the children pages should only appear in the menu when you are on a children page (B, C) or on the parent page (A).
How can I do this? ]]>
...</description>
<content:encoded>
<![CDATA[ <p>I would also like to show the other pages on first level, how can I do that? That means when Im on page B the menu should look like:</p>
<p>– A<br />
– – B<br />
– – C<br />
– D</p>
<p>The same when Im on page C or on page A.</p>
<p>But if Im on page D the menu should look like:</p>
<p>– A<br />
– D</p>
<p>That means the children pages should only appear in the menu when you are on a children page (B, C) or on the parent page (A).</p>
<p>How can I do this?</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Ivanka Murphy </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-743</link>
<dc:creator>
<![CDATA[ Ivanka Murphy ]]>
...</dc:creator>
<pubDate>Sat, 02 Dec 2017 01:40:00 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-743</guid>
<description>
<![CDATA[ Thanks, you saved my life and a lot of time!! ]]>
...</description>
<content:encoded>
<![CDATA[ <p>Thanks, you saved my life and a lot of time!!</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Arts & Sciences Magazine </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-742</link>
<dc:creator>
<![CDATA[ Arts & Sciences Magazine ]]>
...</dc:creator>
<pubDate>Wed, 29 Nov 2017 15:41:00 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-742</guid>
<description>
<![CDATA[ In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-671">Christian Varga</a>.
Thanks again for all this! Question: how would you then either combine this new gist with the pre-existing '// find the top level parent' code, or create a new hook and filter with the 'children_only' option without overwriting the existing function? Basically what I'm attempting is to always display siblings regardless of 1st/2nd/3rd level in the menu. However, if there are children of that page in the menu, display them but only when you're on that particular page. ]]>
...</description>
<content:encoded>
<![CDATA[ <p>In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-671">Christian Varga</a>.</p>
<p>Thanks again for all this! Question: how would you then either combine this new gist with the pre-existing ‘// find the top level parent’ code, or create a new hook and filter with the ‘children_only’ option without overwriting the existing function? Basically what I’m attempting is to always display siblings regardless of 1st/2nd/3rd level in the menu. However, if there are children of that page in the menu, display them but only when you’re on that particular page.</p>
]]>
...</content:encoded>
...</item>
<item>
<title>
By: Christian Varga </title>
<link>https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-739</link>
<dc:creator>
<![CDATA[ Christian Varga ]]>
...</dc:creator>
<pubDate>Sat, 07 Oct 2017 20:40:00 +0000</pubDate>
<guid isPermaLink="false">https://christianvarga.com/?p=198#comment-739</guid>
<description>
<![CDATA[ In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-738">VonWesten</a>.
Is the article part of the menu? ]]>
...</description>
<content:encoded>
<![CDATA[ <p>In reply to <a href="https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-738">VonWesten</a>.</p>
<p>Is the article part of the menu?</p>
]]>
...</content:encoded>
...</item>