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.

Here is a link to my website: website

I have placed the following code to this document in /wp-includes/nav-menu-template.php

Towards the end of the code are several lines that start with $item_output. In particular, you want to look at this piece:

$item_output .= '<a'. $attributes .'>';

Because this line determines the output for the beginning of the link html. I have changed it to something like this:

$item_output .= '<a'. $attributes . 'class="btn btn-warning btn-block"' .'>';

Then all your links in the menu will have class="btn btn-warning btn-block" added to them.


That said, it doesn't allow a custom class for each menu and I several menus that don't need the class="btn btn-warning btn-block" inside of the a link. (or at least I don't know how to code it). This is an issue for me.

Does anyone know how to code this request?

For those asking why would you want to do this? I want to have my main (top) menu links to be buttons.

Here is the function I'm using to call the menu:

<!--buttons-->
<?php







$defaults = array(



'theme_location'  => '',



'menu'            => 'main-nav',



    'container'       => 'ul',



'container_class'    => 'nav navbar-nav',



    'before'          => '',



'after'           => '',



'menu_class'      => '',



'menu_id'         => 'menu',



'echo'            => true,



'fallback_cb'     => 'wp_page_menu',



'link_before'     => '',



'link_after'      => '',



'items_wrap'      => '<div class="col-md-6 col-md-offset-3">%3$s</div>',



'depth'           => 0,



'walker'          => ''



);







wp_nav_menu( $defaults );







?>
share|improve this question
    
It's not recommended to make changes to wordpress core because those changes will be overwritten once wordpress updates. What's the ultimate goal? You should be able to accomplish with filters in functions.php file of your theme. Or just with css. –  gdaniel Aug 21 at 20:17
    
Hi gdaniel, Thanks for your reply. Can you point me in the right direction towards completing this project with filters inside the functions.php? I have no idea where to start? –  Kyle Poyser Aug 21 at 20:45
    
If you all you need is to have you main top menu to be buttons, you can just use the classes that are already available. What are you function are you using to generate the menu? –  gdaniel Aug 21 at 21:44

1 Answer 1

Just use CSS to style your #nav li block.

This is quick, but would make your links into buttons.

    #nav li {
        list-style: none;
        background: #F00;
        width: 120px;
        margin-right: 60px;
        padding: 10px;
        text-align: center;
}

you can add a hover class too like #nav li:hover

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.