" alt="" /> inside wp_nav_menu( array $args = array( 'link_before' => 'ADD_CODE_HERE' )); but " /> " alt="" /> inside wp_nav_menu( array $args = array( 'link_before' => 'ADD_CODE_HERE' )); but " /> " alt="" /> inside wp_nav_menu( array $args = array( 'link_before' => 'ADD_CODE_HERE' )); but "/>

How to add php code inside link_before inside wp_nav_menu()?

157 views Asked by At

I want to add this line <img src="<?php field('text') ?>" alt="" /> inside

wp_nav_menu( array $args = array( 'link_before' => 'ADD_CODE_HERE' ));

but it doesn't work because link_before is for text. Is there any way to add this code?

1

There are 1 answers

5
Fida Al Hasan On BEST ANSWER

Try like this:

wp_nav_menu( array( 'link_before' => '<img src="'. field("text") .'" alt="" />' ));

If your field("text") has proper value then the image will show up.