內容簡介
該外掛提供了在帖子和頁面中標示現有 WordPress 選單的元框。使用者可以通過元數據選擇一個選單,並使其與該帖子或頁面相關聯。
實際上,特色選單與特色圖片完全相同。 帖子或頁面與特色選單僅被附加,您必須使用模板標籤或 WordPress 函數來呈現選單。
請參見其他注意事項來查看範例。
用法
頁面或帖子元數據有一個名為_wp_featured_menu的鍵。 一種非常簡單的呈現菜單的方式是:
<?php
$meta = get_post_custom();
wp_nav_menu( array( 'menu' => $meta['_wp_featured_menu'][0] ) );
?>
更好的方式可能是先測試值:
<?php
$meta = get_post_custom();
if ( is_numeric( $meta['_wp_featured_menu'][0] ) ) {
wp_nav_menu( array( 'menu' => $meta['_wp_featured_menu'][0] ) );
}
?>
外掛標籤
開發者團隊
原文外掛簡介
This plugin provides a metabox on posts and pages listing existing WordPress Menus. The end user is allowed to choose one and make it associated with the post or page via meta data.
Practically speaking, Featured Menus work exactly like Featured Images. The Post or Page and Featured Menu are merely attached, and you must use a template tag or WordPress functions to render the Menu.
Please see Other Notes for examples.
Usage
Page or Post meta has a key called _wp_featured_menu. A very simple way to render the menu is like this:
$meta['_wp_featured_menu'][0] ) );
?>
A better way might be to test for the value first:
$meta['_wp_featured_menu'][0] ) );
}
?>
