Posts

Showing posts with the label wp_nav_menu

How to add image option in nav menu in wordpress

Just copy and paste below code into your theme's functions.php or your's custom plugin file and change according to your need. Here is my code for add menu image with different hover image <?php class RJ_Menu_Image_Plugin {         public function __construct() {         add_action( 'init', array( $this, 'init' ) );         add_filter( 'manage_nav-menus_columns', array( $this, 'manage_nav_menu_image_column' ), 11 );         add_action( 'admin_head-nav-menus.php', array( $this, 'enqueue_js_for_nav_menu' ) );         add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item_menu_image' ) );         add_filter( 'walker_nav_menu_start_el', array( $this, 'walker_nav_menu_start_el' ), 10, 4 );         add_action( 'admin_action_delete-menu-item-image', array( $...

How to add a custom menu properties in menu item in wordpress

For add a custom menu properties in menu item just copy and paste below code into your theme's functions.php file or into your custom plugin file and do field's changes according to your need. Here i add a custom menu icon option for menu item. add_filter( 'wp_setup_nav_menu_item', 'rj_add_custom_nav_fields' );         // save menu custom fields add_action( 'wp_update_nav_menu_item',  'rj_update_custom_nav_fields', 10, 3 ); // edit menu walker add_filter( 'wp_edit_nav_menu_walker',  'rj_edit_walker', 10, 2 ); function rj_add_custom_nav_fields( $menu_item ) {             $menu_item->icon = get_post_meta( $menu_item->ID, '_menu_item_icon', true );         return $menu_item; } function rj_update_custom_nav_fields( $menu_id, $menu_item_db_id, $args ) {      // Check if element is properly sent         if ( is_array( $...

How to change wp_nav_menu walker or any other argument by filter in wordpress

For change wp_nav_menu argument for specific menu or all menu or change walker class for menu just copy and paste below code into your theme's functions.php file and change menu slug as per your need add_filter('wp_nav_menu_args','rj_change_walker_for_footer_menus',10,1); function rj_change_walker_for_footer_menus($args) {     global $wpdb;     if($args['menu']!='' && in_array($args['menu']->slug,array('footer-menu1','footer-menu2','footer-menu3')))     {         $args['fallback_cb']           = 'RJFusionFootermenuWalker::fallback';             $args['walker']    =new RJFusionFootermenuWalker();     }     return $args; }

How to change navigation menu display style in wordpress

<?php For change navigation menu display style you need to call your custom walker class. When you can your navgation menu just add walker argument in it and initialize your walker class.. wp_nav_menu(array(                 'theme_location'    => 'main_navigation',                 'depth'                => 5,                 'menu_class'          => 'fusion-menu',                 'items_wrap'         => '<ul id="%1$s" class="%2$s">%3$s</ul>',         ...