0
votes

I'm working on a Wordpress theme on my local machine and i thought it would be cool to use bootstrap with it. I build the website already in html/css but wanted to upload it to Wordpress (To learn wordpress).

Now i'm rebuilding my nav section because i want it to make it customable in my admin-panel. I'm using:

<?php $args = array( 'theme_location' => 'header' ); ?>
<?php wp_nav_menu( $args ); ?>

The bowser displayed a div>ul>li>a. I edited the div, ul and li's class to bootstrap classes but now i need to get an A class of nav-link to my a tag.

This is what my bowser gives me now:

<div class="collapse navbar-collapse" id="navbarCollapse">
  <ul class="navbar-nav ml-auto">
    <li class="nav-item">
      <a href="http://localhost/wordpress/index-html">Homepage</a>
    </li>
  </ul>
</div>

This is what i want.

<a href="http://localhost/wordpress/index-html" class="nav-link">Home</a>

I'm editing my nav-menu-template.php now but can't find it. Where can i change the classes of the A tag in wp_nav_menu();

(I know that someone else asked this aswell, but i couldn't get that code to work. Maybe because the commands where from 2014 or maybe because i did something wrong.)

1
This has been answered here in the past: stackoverflow.com/questions/26180688/… - JDewitt

1 Answers

0
votes

You may have some luck looking through your theme's functions.php file. Try looking for the wp_nav_menu function in that file, and see what that gets you.

The code you're looking for may be in functions.php, or you may find a reference in that file to another file.

How this stuff gets handled can vary widely based on how the template is constructed, which may be why you didn't have much luck searching for the answer.

Best of luck!