Pregunta

I install wp on my localhost, Now i want to add class for menu links but i don't know where, code look like this:

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); >

where i there need to add my css class for change fonts color,size,underline of menu links ? Thanks.

¿Fue útil?

Solución

You can use CSS to make your styles specific depending on what element they are inside. You can see what I mean in this jsfiddle. Notice how all of the links are the colors you have asked for, but the links inside the ul with a nav-menu class are different colors. This is the kind of code you will need to add to styles.css. You can also change the class of the output by WordPress in your PHP code like this:

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'my-custom-class' ) ); >

If you're having a problem with your code getting overwritten, try adding it to the very very bottom. CSS interprets things at the bottom of your file as more important than things at the top.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top