Blog Single Page

Using shortcode inside wordpress menu labels

By on 22 December 2013

Using shortcode inside wordpress menu labels

Yesterday I faced an issue while using the shortcode inside wordpress menues .I searched and searched but did not found any solution .I found few hints in which new walker class was used .
After lot of problems I found a solution .

You can add a shortcode inside your menus .
First you need to register a shortcode and write your function which will be called on behind of shortcode .You can echo some string in the menues

add_shortcode("SHORTCODE","shortcode_function");
function shortcode_function() {

$test = "Test"
return $test;
}

After writing shortcode you just need to add a filter which will execute the shortcode .

add_filter('wp_nav_menu_items', 'do_shortcode');

0 Replies to “Using shortcode inside wordpress menu labels”

Leave a Reply

Your email address will not be published. Required fields are marked *

five × four =