WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] $args 'menu' => 'main-menu' (3 posts)

  1. Linards
    Member
    Posted 10 months ago #

    Hi,

    has anyone have an idea how to add current page for the menu?

    I have this code for my pages:

    <?php
        $args = array(
            'menu' => 'main-menu',
        );
        wp_nav_menu ( '$args');
    ?>

    I would like to highlight the current page with some css, but dont know how to add the dynamic class.

    Any ideas?

    menu on IMGUR

    Many thanks.

  2. ronangelo
    Member
    Posted 10 months ago #

    @linards
    No need to add your own class for currently displayed pages on the menu as WordPress already outputs some default class you could use.
    .current-menu-item and .current_page_item

    ex.

    .current-menu-item,
    .current_page_item {background-color: #FFFFFF;}

    or

    .current-menu-item a,
    .current_page_item a {background-color: #FFFFFF;}
  3. Linards
    Member
    Posted 9 months ago #

    Thank you

Reply

You must log in to post.

About this Topic

Tags