[WordPress] 外掛分享: WP Featured Menus

首頁外掛目錄 › WP Featured Menus
10+
安裝啟用
尚無評分
3863 天前
最後更新
問題解決
WordPress 3.0+ v1.3.1 上架:2014-06-22

內容簡介

該外掛提供了在帖子和頁面中標示現有 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] ) );
}
?>

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.3.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「WP Featured Menus」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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] ) );
}
?>

延伸相關外掛

文章
Filter
Mastodon