WordPress.org

Forums

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

  1. Linards
    Member
    Posted 1 year 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 1 year 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 1 year ago #

    Thank you

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags