Keep active class in post page
Keep active class in post page
Keep active class in post page
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
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
For anyone looking for this same solution I figured it out (apart from adding a different class to parents and children, unfortunately this puts the parent in the same nest as its children but with css and query ill be able to differentiate these. Here is the code; <?php global $authordata, $post; $authors_posts = get_posts( … Read more
This isn’t a WordPress question, its more suitable for StackOverflow. Regardless, your looking for a chained menu. I’ve seen this tutorial around a lot, hope it helps.
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
I solved it. I thought it could work but i wasn’t sure, and i wanted some opinion from more experienced people. Anyways, this is what i have done: First of all, i defined a private var in my walker class: private $el; In my start_el() function, i filled this var with $item $this->el = $item; … Read more
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
Use wp_login_url() function with get_permalink() as a parameter, if a user is not logged in. Something like this: <a href=”https://wordpress.stackexchange.com/questions/210374/<?php echo wp_login_url( get_permalink() ); ?>” title=”Login”>Login</a> And wp_logout_url function with get_permalink() as a parameter, if a user is logged in. <a href=”https://wordpress.stackexchange.com/questions/210374/<?php echo wp_logout_url( get_permalink() ); ?>”>Logout</a> EDIT: instead of using 2 different functions, you … Read more
automatically adding submenu items