I have created a menu item with this code. The menu item appears but the short output is not there, is there something that I can add or a different method that will do this. I have also added in the hope that it can help.
add_filter ('wp_nav_items', 'do_shortcode', 7); Or maybe someone knows that this is not possible and can tell me.
/ * Avia Menu * / function add_profile_link_to_nav () {if_user_logged_in ()) {? & Gt; & Lt; Ul & gt; & Lt; Li class = "menu-item" id = "one" & gt; & Lt; A href = "http://example.com/members/" & gt; All members & lt; / A & gt; & Lt; Ul class = "sub-menu" & gt; & Lt; Li class = "menu-item" & gt; & Lt ;? Php echo custom_execute_shortcode (); ? & Gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt ;! - End menu --- & gt; & Lt ;? Php}} add_action ("wp_nav_items", "add_profile_link_to_nav"); Function custom_execute_shortcode () {$ myfunction = '[my shortcode]'; $ Myfunction_parsed = do_shortcode ($ myfunction); Return $ myfunction_parsed;} thanks
On the menu page Can not use shortcodes directly in the menu URL, because the brackets are stripped. But you can use placeholders like this: #profile_link # . With the following code in functions.php , you can create a custom menu item with the URL # Profile_link # , and it is available in your shortcode Will replace with. / ** * #placeholder # All menu item filters for url. * * @Web WP_Post [] $ menu_items All new menu items sorted for display. * * @Rutturn WP_Post [] Menu items are filled properly with any placeholders. * / Function my_dynamic_menu_items ($ menu_items) {// to change list of placeholders. // You can add more placeholders to the list according to the need. $ Placeholders = array ('#profile_link #' => Array ('Shortcodes' = & gt; 'my_shortcode', 'atts' = & gt; array (), // shortcode attribute. 'Content' = & gt; ; '', // content for shortcode.),); Forex Currency ($ menu_items $ as menu_item) {if (isset ($ placeholders [$ menu_item-> URL])) {global $ shortcode_tag; $ Placeholder = $ placeholder [$ menu_item- & gt; Url]; $ ($ Shortcodes_tags [$ placeholder ['shortcode']]) {$ menu_item-> Url = call_user_func ($ shortcodes_tags [$ placeholder [shortcode]], $ placeholder ['ets'], $ placeholder ['content'], $ placeholder ['shortcode']); }}} Return $ Menu_items; } Add_filter ('wp_nav_menu_objects', 'my_dynamic_menu_items'); All you have to do is set up in 'shortcode' $ placeholders , and optionally 'atts' and 'Content' . For example, if your shortcode is such:
[example id = "5" other = "test"] shortcode content [/ example] You will update:
'# placeholder #' = & gt; Array ('shortcode' = & gt; 'example'; 'ets' => array (' id '=> 5', 'other' = & gt; 'test'); 'content' = & Gt; ';),
Note that because this is a resource intensive task and in this case the job is not the right tool.
Comments
Post a Comment