Can you please clarify, in what circumstances you need this slug?
OK, I need the permalink of menu items, as each item will display their information independently on a single page, then wanted to know how can get the slug of the items or the permanent link to the template “foodlist_menu_item_template”, i’m using a filter like this:
function tm_menu_item_template( $tpl ) {
if ( is_page_template( 'template-menu.php' ) ) {
$tpl = '
<div class="fl-menu-item" id="fl-menu-item-[menu_item_id]-[menu_item_instance]">
[menu_item_thumbnail]
<h2>[menu_item_title]</h2>
<div class="item-overlay">
<div class="item-inner">
<a id="fl-menu-item-url-[menu_item_id]" href="#_i_need_permalink_here">[menu_item_thumbnail]</a>
<h2>[menu_item_title]</h2>
<div class="fl-excerpt">
[menu_item_excerpt]
</div>
<a id="fl-menu-item-url-h2-[menu_item_id]" class="menu-item-button" href="#_i_need_permalink_here">View More</a>
</div>
</div>
</div>
';
}
return $tpl;
}
add_filter( 'foodlist_menu_item_template', 'tm_menu_item_template', 10, 2 );
See #_i_need_permalink_here.
Well, currently it seems impossible. As a workaround you can do it this way: http://yoursiteurl/?p=[menu_item_id]
(it should then redirect to the permalink). However, this is not an ideal solution, and I will create a shortcode to output both permalink and slug in future versions.
Please check the new release. There are 3 new template shortcodes:
menu_permalink
, menu_section_permalink
and menu_item_permalink
(you can use them in the correspondent templates).
I didn’t test much separate custom posts with menu item, menu section or menu. Please let me know if you encounter any problem.
Thanks, works great, and I’ll let you know of any bug.