Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP How to Build a WordPress Theme Converting Static HTML into WordPress Templates Coding the Header and Footer Templates

My strip_tags() function doesn't seem to be working... It just keeps showing the ul and li

This is what I have:

<?php

$arg = array( 
    'menu' => 'main_menu',
    'echo' => false
);

echo strip_tags( wp_nav_menu($args), "<a>");

?>

1 Answer

Sean T. Unwin
Sean T. Unwin
28,690 Points

I noticed in your code block that the variable is defined as $arg while the variable $args (notice the 's'; plural) is being passed in the wp_nav_menu() function.

In order to remove the <ul> and <li> tags refactor your code to include two other items to $args array:

$args = array( 
    'menu' => 'main_menu',
    'echo' => false,
    'items_wrap' => '%3$s',
    'depth' => 0
);
echo strip_tags( wp_nav_menu($args), "<a>");

Thank you so much!! I can't believe I didn't see that!! :)