I was working with WordPress since long time and I am becoming familiar with more and more built in functions and usage of WordPress functions. Really, WordPress makes life more easier than we think. As i developer, you should know argument of functions and how to make it more and more flexible. I was using wp_nav_menu function for footer menu and I would like to remove div tags, ul tags and li tags. I just need to put <a> tags.
If you do not need ul tags in wp_nav_menu function, you just need to pass below argument in wp_nav_menu function’s parameter.
Just pass above argument and you will get output with out ul tags.
Now you want remove li tags. WordPress does not have anything and they will return li tags in output. so we need to remove li tags manually using our code. Look at below code.
$args = array( 'echo' => false, 'items_wrap' => '%3$s', ); echo strip_tags(wp_nav_menu( $args), '<a>' );
Here, we are passing false to echo argument so it will give us the output instead of direct print. Once we get the output, we have passed it in strip_tags function to remove all html tags but passing <a> which is exceptional. so other than <a>, we have li tags which will be removed. That’s it.