Comments on: How to get submenu items from a WordPress menu based on parent or sibling https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/ Mon, 08 Feb 2021 02:00:26 +0000 hourly 1 https://wordpress.org/?v=6.6.2 By: Hitesh Patel https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-770 Mon, 08 Feb 2021 02:00:26 +0000 https://christianvarga.com/?p=198#comment-770 It is very good and working fine with all options but in my side not working on my single.php any solution?

]]>
By: Darek Podbereski https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-758 Sun, 01 Dec 2019 22:05:20 +0000 https://christianvarga.com/?p=198#comment-758 In reply to Peter Westerlund.

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.

]]>
By: Peter Westerlund https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-753 Wed, 15 May 2019 14:50:28 +0000 https://christianvarga.com/?p=198#comment-753 I just gets an infinite loop. What could be the problem?

]]>
By: Marco Rx https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-752 Thu, 09 May 2019 20:45:40 +0000 https://christianvarga.com/?p=198#comment-752 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

]]>
By: Christian Schlender https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-748 Thu, 20 Sep 2018 14:33:15 +0000 https://christianvarga.com/?p=198#comment-748 In reply to Christian Varga.

Works perfect, thank you very much 🙂

]]>
By: Christian Varga https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-747 Sat, 08 Sep 2018 02:11:11 +0000 https://christianvarga.com/?p=198#comment-747 In reply to Christian Schlender.

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

! empty( $item->menu_item_parent )

I’ve created a gist for you here: https://gist.github.com/levymetal/c5cde99d888982205ebed75288618d80

]]>
By: Christian Schlender https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-746 Wed, 05 Sep 2018 22:19:13 +0000 https://christianvarga.com/?p=198#comment-746 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?

]]>
By: Ivanka Murphy https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-743 Sat, 02 Dec 2017 01:40:00 +0000 https://christianvarga.com/?p=198#comment-743 Thanks, you saved my life and a lot of time!!

]]>
By: Arts & Sciences Magazine https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-742 Wed, 29 Nov 2017 15:41:00 +0000 https://christianvarga.com/?p=198#comment-742 In reply to Christian Varga.

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.

]]>
By: Christian Varga https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-739 Sat, 07 Oct 2017 20:40:00 +0000 https://christianvarga.com/?p=198#comment-739 In reply to VonWesten.

Is the article part of the menu?

]]>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0">
<channel>
<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 &lt;a href=&quot;https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-753&quot;&gt;Peter Westerlund&lt;/a&gt;. 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>
<![CDATA[ Marco Rx ]]>
</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&#039;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&#8217;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 &lt;a href=&quot;https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-747&quot;&gt;Christian Varga&lt;/a&gt;. 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 &lt;a href=&quot;https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-746&quot;&gt;Christian Schlender&lt;/a&gt;. Hey Christian, you&#039;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 &lt;code&gt;! empty( $item-&#062;menu_item_parent )&lt;/code&gt; I&#039;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&#8217;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-&gt;menu_item_parent )</code></p> <p>I&#8217;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 &#38; 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 &lt;a href=&quot;https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-671&quot;&gt;Christian Varga&lt;/a&gt;. Thanks again for all this! Question: how would you then either combine this new gist with the pre-existing &#039;// find the top level parent&#039; code, or create a new hook and filter with the &#039;children_only&#039; option without overwriting the existing function? Basically what I&#039;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&#039;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 &#8216;// find the top level parent&#8217; code, or create a new hook and filter with the &#8216;children_only&#8217; option without overwriting the existing function? Basically what I&#8217;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&#8217;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 &lt;a href=&quot;https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/#comment-738&quot;&gt;VonWesten&lt;/a&gt;. 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>
</channel>
</rss>