top of page

Walker Menu in WordPress

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Nov 18, 2021
  • 1 min read




/*Custom Header Menu*/
class IBenic_Walker extends Walker_Nav_Menu {
    
    function start_el(&$output, $item, $depth=0, $args=array(), $id = 0) {
    	$object 			= $item->object;
    	$type 				= $item->type;
    	$title 				= $item->title;
    	$description 		= $item->description;
    	$permalink 			= $item->url;


    	$anchorclass = '';
    	if($item->ID == 1372){
    		$anchorclass = 'btn';
    	}


    	

    	$output .= "<li class='" .  implode(" ", $item->classes) . "'>";

      if( $permalink && $permalink != '#' && $depth == 0  ) {
      	$output .= "<a class='".$anchorclass."' href='" . $permalink . "'><img src='".$description."'/><span>";

      	$output .= $title;
      }else{

      	$output .= "<a class='".$anchorclass."' href='" . $permalink . "'><span>";

      	$output .= $title;
      }



      if( $permalink && $permalink != '#' ) {
      	$output .= '</span></a>';
      } 
    }
}



 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page