wp_nav_menu
-
I’m trying to get a menu working without the container, ul, and li. My end goal is:
<a class="hp_signnav" id="services" href="linkhere"></a> <a class="hp_signnav" id="packages" href="linkhere"></a> <a class="hp_signnav" id="portfolio" href="linkhere"></a> <a class="hp_signnav" id="products" href="linkhere"></a>
By using the PHP code:
$menuParameters = array( 'theme_location' => 'homepage-menu', 'echo' => false, 'fallback_cb' => '', 'items_wrap' => '%3$s', 'depth' => 0, ); echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
I got to here (with corrent hrefs):
<a href="linkhere"></a> <a href="linkhere"></a> <a href="linkhere"></a> <a href="linkhere"></a>
I then added this in my functions file to add a class to each, but it is a static class.
function add_nav_class($output) { $output= preg_replace('/<a/', '<a class="hp_signnav" id=""', $output, -1); return $output; } add_filter('wp_nav_menu', 'add_nav_class');
That got me to here:
<a class="hp_signnav" href="linkhere"></a> <a class="hp_signnav" href="linkhere"></a> <a class="hp_signnav" href="linkhere"></a> <a class="hp_signnav" href="linkhere"></a>
So I need help with two things. How can I add the slug of the page to the ‘s ID? Also, can I change the filter so that it only applies these to a single menu?
Thanks for the help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘wp_nav_menu’ is closed to new replies.