? Markup: ...">

How to add <a> id to Wordpress menu for toolbar?

How to hide this html menu in Wordpress menu and how to enable it <a id="">

?

Markup:

<ul>
    <li><a id="home" href="">???</a></li>
    <li><a id="description" href="">???</a></li>
    <li><a id="about" href="">?</a></li>
    <li><a id="shop" href="">????</a></li>
    <li><a id="blog" href="">???</a></li>
</ul>

      

I am trying to make the default Wordpress menu code in header.php

<?php

if (function_exists('wp_nav_menu')) {
    wp_nav_menu(array(
        'theme_location' =>  'wpj-main-menu', 
        'fallback_cb' => 'wpj_default_menu')
    );
}
else {
    wpj_default_menu();
}

?>

add_action('init', 'wpj_register_menu');

function wpj_register_menu() {
    if (function_exists('register_nav_menu')) {
        register_nav_menu( 'wpj-main-menu', __( 'Main Menu', 'brightpage' ) );
    }
}

function wpj_default_menu() {
    echo '<ul>';
    if ('page' != get_option('show_on_front')) {
        echo '<li><a href="'. home_url() . '/">Home</a></li>';
    }
    wp_list_pages('title_li=');
    echo '</ul>';
}

      

I am also trying to do echo '<li><a id="home" href="'. home_url() . '/">Home</a></li>';

But how do I change those <a>

id's in the control panel?

Please help me. Thank.

+3


source to share


1 answer


Instead of identifiers, you can add classes to each element.

From the menu at the end of Wordpress, you can select screen options and check the box for css classes.

Then you can add a unique class name to each menu item.



Your classes will add LI elements and then select links by doing

.home a {}

.description a {}

.about a {}

.shop a {}

.blog a {}

      

+6


source







All Articles