<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>custom menu in wordpress Archives - Cody Paste</title>
	<atom:link href="https://www.codypaste.com/tag/custom-menu-in-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codypaste.com/tag/custom-menu-in-wordpress/</link>
	<description>THE WEB PLAYGROUND</description>
	<lastBuildDate>Sat, 03 Aug 2019 09:17:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.codypaste.com/wp-content/uploads/2022/12/cropped-codypaste-32x32.png</url>
	<title>custom menu in wordpress Archives - Cody Paste</title>
	<link>https://www.codypaste.com/tag/custom-menu-in-wordpress/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Create Custom Menu in WordPress</title>
		<link>https://www.codypaste.com/create-custom-menu-in-wordpress/</link>
					<comments>https://www.codypaste.com/create-custom-menu-in-wordpress/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Tue, 07 May 2019 12:57:33 +0000</pubDate>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom main menu in wordpress]]></category>
		<category><![CDATA[custom menu in wordpress]]></category>
		<category><![CDATA[Walker menu]]></category>
		<guid isPermaLink="false">http://www.codypaste.com/?p=711</guid>

					<description><![CDATA[<p>Register and  Create Custom Menu in WordPress, WordPress Menu Walker Register New Menu in &#8216;Menu Setting&#8217; Appearance -&#62; Menu Add in function.php [crayon-69abfea635640055820141/] &#160; For Adding extra CSS class in menu &#60;li&#62; (in function.php) [crayon-69abfea63565f524763645/] &#160; Main Walker menu (in function.php) [crayon-69abfea635663797424321/] &#160; Use this code where you want to appear menu (header.php) [crayon-69abfea635667971878517/] &#160;</p>
<p>The post <a href="https://www.codypaste.com/create-custom-menu-in-wordpress/">Create Custom Menu in WordPress</a> appeared first on <a href="https://www.codypaste.com">Cody Paste</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Register and  Create Custom Menu in WordPress, WordPress Menu Walker</strong></p>
<p>Register New Menu in &#8216;Menu Setting&#8217; <strong>Appearance -&gt; Menu</strong></p>
<p>Add in <strong>function.php</strong></p><pre class="urvanov-syntax-highlighter-plain-tag">/*Register Menu*/
function register_my_menus() {
register_nav_menus(
array(
'header-menu' =&gt; __( 'Header Menu' ),
'extra-menu' =&gt; __( 'Extra Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );</pre><p>&nbsp;</p>
<p><strong><em>For Adding extra CSS class in menu &lt;li&gt; (in function.php)</em></strong></p><pre class="urvanov-syntax-highlighter-plain-tag">function add_additional_class_on_li($classes, $item, $args) {
    if($args-&gt;add_li_class) {
        $classes[] = $args-&gt;add_li_class;
    }
    return $classes;
}
add_filter('nav_menu_css_class', 'add_additional_class_on_li', 1, 3);</pre><p>&nbsp;</p>
<p><em><strong>Main Walker menu (in function.php)</strong></em></p><pre class="urvanov-syntax-highlighter-plain-tag">class Nfr_Menu_Walker extends Walker_Nav_Menu{

                /**
         * Traverse elements to create list from elements.
         *
         * Display one element if the element doesn't have any children otherwise,
         * display the element and its children. Will only traverse up to the max
         * depth and no ignore elements under that depth. It is possible to set the
         * max depth to include all depths, see walk() method.
         *
         * This method shouldn't be called directly, use the walk() method instead.
         *
         * @since 2.5.0
         *
         * @param object $element Data object
         * @param array $children_elements List of elements to continue traversing.
         * @param int $max_depth Max depth to traverse.
         * @param int $depth Depth of current element.
         * @param array $args
         * @param string $output Passed by reference. Used to append additional content.
         * @return null Null on failure with no changes to parameters.
         */
        function display_element( $element, &amp;$children_elements, $max_depth, $depth=0, $args, &amp;$output ) {

                if ( !$element )
                        return;

                $id_field = $this-&gt;db_fields['id'];

                //display this element
                if ( is_array( $args[0] ) )
                        $args[0]['has_children'] = ! empty( $children_elements[$element-&gt;$id_field] );

                //Adds the 'parent' class to the current item if it has children               
                if( ! empty( $children_elements[$element-&gt;$id_field] ) ) {
                        array_push($element-&gt;classes,'parent');
                        $element-&gt;title .= ' &lt;i class="ion-android-arrow-dropdown"&gt;&lt;/i&gt;';
                }

                $cb_args = array_merge( array(&amp;$output, $element, $depth), $args);

                call_user_func_array(array(&amp;$this, 'start_el'), $cb_args);

                $id = $element-&gt;$id_field;

                // descend only when the depth is right and there are childrens for this element
                if ( ($max_depth == 0 || $max_depth &gt; $depth+1 ) &amp;&amp; isset( $children_elements[$id]) ) {

                        foreach( $children_elements[ $id ] as $child ){

                                if ( !isset($newlevel) ) {
                                        $newlevel = true;
                                        //start the child delimiter
                                        $cb_args = array_merge( array(&amp;$output, $depth), $args);
                                        call_user_func_array(array(&amp;$this, 'start_lvl'), $cb_args);
                                }
                                $this-&gt;display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
                        }
                        unset( $children_elements[ $id ] );
                }

                if ( isset($newlevel) &amp;&amp; $newlevel ){
                        //end the child delimiter
                        $cb_args = array_merge( array(&amp;$output, $depth), $args);
                        call_user_func_array(array(&amp;$this, 'end_lvl'), $cb_args);
                }

                //end this element
                $cb_args = array_merge( array(&amp;$output, $element, $depth), $args);
                call_user_func_array(array(&amp;$this, 'end_el'), $cb_args);
        }
}</pre><p>&nbsp;</p>
<p><em><strong>Use this code where you want to appear menu (header.php)</strong></em></p><pre class="urvanov-syntax-highlighter-plain-tag">&lt;nav class="overlay-menu-nav"&gt;
			&lt;?php 
			//wp_nav_menu( array( 'theme_location' =&gt; 'header-menu' ) );
								
				$walker = new Nfr_Menu_Walker(); 
				wp_nav_menu( array( 
					'theme_location' =&gt; 'header-menu',
					'container' =&gt; false,
					'menu_id' =&gt; 'nav',
					'add_li_class'  =&gt; 'slidedown',
					'depth' =&gt; 3,	
					'walker' =&gt; $walker 
				) ); 

			?&gt;				
			&lt;/nav&gt;</pre><p>&nbsp;</p>
<p>The post <a href="https://www.codypaste.com/create-custom-menu-in-wordpress/">Create Custom Menu in WordPress</a> appeared first on <a href="https://www.codypaste.com">Cody Paste</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codypaste.com/create-custom-menu-in-wordpress/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
