Quick question from a php newbie

Hey there,

I creating a wordpress template and I’m able to do simple php stuff. But at the end of the day I really don’t know PHP very well yet. Which leads me to this question.

I’m creating a secondary navagation to appear only on certain pages. I got that code down.

<?php if (is_page(15)|| is_page(34) || is_page(18)) {
	
 if ( has_nav_menu( 'secondary' ) )
	 
{  wp_nav_menu( array( 'theme_location' => 'secondary' ) ); }
?>

I know that wordpress will create the UL’s and LI’s and whatnot but I want to wrap this nav bar in a div so I can position and style it.

So where in that code do I add the <div id=“#”></div> tags in that code. I tried a bunch of different stuff but I can’t seem to figure this out.

Thanks,
Daniel

Documentation for it is here:
Function Reference/wp nav menu « WordPress Codex

You’d essentially want to pass in an array key, you can speciy container (which defaults as div),
and a container_id, along with a lot of other things specified in the documentation.

So modifying the array you pass in like so


wp_nav_menu( array( 'theme_location' => 'secondary', 'container_id' => 'myCssId') );

Would give the div container an id of ‘myCssId’ - there’s a ton of parameters you can pass in though to modify how it works, before, after, etc - So I’d check out the documentation link I posted in the beginning of this post.