Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've got a dynamic menu being generated, but instead of generating a page-item it generates a menu-item. What I would like it to do is generate page-items and all the rest of it so that I can show or highlight the current page a user is visiting.

my code is :

// header.php

<?php // Loading WordPress Custom Menu
    wp_nav_menu( array(
        'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
        'menu_class'      => 'nav navbar-nav',
        'menu_id'         => 'main-menu',
        'walker'          => new Cwd_wp_bootstrapwp_Walker_Nav_Menu()
) ); ?>

And then in the functions.php I have

add_action( 'after_setup_theme', 'cwd_wp_bootstrapwp_theme_setup' );
if ( ! function_exists( 'cwd_wp_bootstrapwp_theme_setup' ) ):
function cwd_wp_bootstrapwp_theme_setup() {
    // Adds the main menu
    register_nav_menus( array(
        'main-menu' => __( 'Main Menu', 'cwd_wp_bootstrapwp' ),
    ) );
}
endif;
share|improve this question
    
Do you mean highlight the menu item in the menu? –  Brad Dalton Feb 21 at 2:08
    
Yes, so if you're on the blog page highlight the menu item that says blog. –  Dominic Francis Feb 21 at 8:17

1 Answer 1

This is an example of CSS code which works with one specific theme.

You may need to change the classes depending on your theme.

.nav-primary .current-menu-item > a  {
color: blue;
background-color: white;
}

This will highlight the background color of the current menu item to white and you can also change the font color which in this case is blue.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.