How can I add a sub menu to an existing navigation menu in WordPress?

I got the answer, here it is: I want to add submenus ffrom database to the menu named ‘Products’ Create a custom plugin and install it through Admin panel. Inside the functions.php write this code. This is upgrade safe way and will not brake if the theme is updated. add_filter( ‘wp_nav_menu_objects’, ‘ravs_add_menu_parent_class’ ); function ravs_add_menu_parent_class( … Read more

Extend walker – navigation, adding data attribute to a tag

This is how I added data attribute to my menu It simply adds data-title=”menu-title” to each link on my main nav, change it to adapt to your need. You don’t actually need to use Nav Walker to add this add_filter( ‘nav_menu_link_attributes’, ‘cfw_add_data_atts_to_nav’, 10, 4 ); function cfw_add_data_atts_to_nav( $atts, $item, $args ) { $atts[‘data-title’] = $item->post_title; … Read more

Hide menu items for visitors and filter based on role

You need to define something like this in your header.php file. <?php if ( is_user_logged_in() ) { echo ‘Welcome, registered user!’; } else { echo ‘Welcome, visitor!’; } ?> Create a new role with the following code and put it in your functions.php add_role(‘partners’, ‘Partners’, array( ‘read’ => true, // True allows that capability, False … Read more

How to Create a Custom WordPress Navigation Menu with the Code?

Well first of all you can use the menu feature in the newer WordPress. First you want to activate the fact that you want to use this feature via your functions.php file. // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( ‘primary’ => __( ‘Primary Navigation’, ‘your_theme_name’ ), ‘secondary’ => __(‘Secondary Navigation’, ‘your_theme_name’) ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)