Hallo @mabufoysal,
you can do this via PHP. But if you want to do that, you can try to use this plugin:
https://wordpress.org/plugins/megamenu/
PHP Example without Plugin:
if ( ! has_filter( 'wp_nav_menu', 'do_shortcode' ) ) {
add_filter( 'wp_nav_menu', 'shortcode_unautop' );
add_filter( 'wp_nav_menu', 'do_shortcode', 11 );
}
Documentation: https://developer.wordpress.org/reference/functions/wp_nav_menu/
Greetings
Benjamin
Thanks @benjamin_zekavica .
Sorry, I couldn’t express myself properly. I created a Shortcode named country_name
and it is working perfectly in Posts.
But I would like to use this shortcode with Menu like the screenshot. May be you are clear after check the screenshot.
This Shortcode will show a Country name.
How can I use the Shortcode with the menu like the screenshot ?
Thanks @benjamin_zekavica . How to use wp_nav_menu
filter ? I am using like below.
add_shortcode('country_name', 'country_name_shortcode');
function country_name_shortcode($country_name) {
return $country_name;
}
add_filter( 'wp_nav_menu', 'country_name_shortcode' );
Just use :
if ( ! has_filter( 'wp_nav_menu', 'do_shortcode' ) ) {
add_filter( 'wp_nav_menu', 'shortcode_unautop' );
add_filter( 'wp_nav_menu', 'do_shortcode', 11 );
}
in addition to your shortcode coding. With the above 4 lines you activate the use of shortcode in the menu. Add them there where you add your shortcode-code.
Thanks @threadi and @benjamin_zekavica. Your solution works like Magic. Thanks.