久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網(wǎng)站+自適應網(wǎng)頁多模板選擇-建站388元起價!!!
當前位置:主頁 > 網(wǎng)站建設(shè) > wordpress自定義導航菜單如何使用?,建站文章

wordpress自定義導航菜單如何使用?,建站文章

時間:2023-07-23 10:07:23 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: IT網(wǎng)站員

導讀:建站文章建站文章一、在wordpress模板中添加注冊菜單代碼。 首先要注冊菜單,將以下函數(shù)添加至function.php函數(shù)里: register_nav_menus(arr快速建站技術(shù)國外技術(shù)網(wǎng)站。

快速建站技術(shù)國外技術(shù)網(wǎng)站

一、在wordpress模板中添加注冊菜單代碼。

首先要注冊菜單,將以下函數(shù)添加至function.php函數(shù)里:

register_nav_menus(array( 'PrimaryMenu'=>'導航', 'friendlinks'=>'友情鏈接', 'footer_nav'=>'頁腳導航')); add_theme_support('nav_menus');

‘PrimaryMenu’=>’導航’

這個表示導航欄的名稱,左邊是別名,右邊是名稱。別名會用在導航欄的調(diào)用上,名稱則顯示在菜單后臺頁面上

添加上述函數(shù)后,進入wp后臺,在左側(cè)菜單的“外觀”里即多了“菜單”選項

二、在wordpress網(wǎng)站后臺創(chuàng)建菜單。

創(chuàng)建一個名稱為“導航欄”的菜單。

可以看到主題位置顯示了三個位置,即剛才我們添加到function.php的函數(shù)里設(shè)置的。

在后臺創(chuàng)建了菜單,并勾選主題位置后,開始下一步。

三、在wordpress模板中引用菜單。

在主題文件對應位置,引用導航欄。需要用到下面這個函數(shù)。

<?php wp_nav_menu( array( 'theme_location'手機模板dede => '',//導航別名 'menu' => '', //期望顯示的菜單 'container' => 'div', //容器標簽 'container_class' => '',//ul父節(jié)點class值 'container_id' => '', //ul父節(jié)點id值 'menu_class' => 'menu', //ul節(jié)點class值 'menu_id' => '', //ul節(jié)點id值 'echo' => true,//是否輸出菜單,默認為真 'fallback_cb' => 'wp_page_menu', //菜單不存在時,返回默認菜單,設(shè)為false則不返回 'before' => '', //鏈接前文本 'after' => '', //鏈接后文本 'link_before' => '', //鏈接文本前 'link_after' => '',//鏈接文本后 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', //如何包裝列表 'depth' => 0, //菜單深度,默認0 'walker' => '' //自定義walker ) ); ?>

這些是幾乎所有的參數(shù),還有一個item_space參數(shù)沒寫進去,覺得沒什么必要。接著來講講這些參數(shù)如何使用,并給出了相應例子,以供參考。

最簡單的用法:

<?php wp_nav_menu( array( 'theme_location'=>'PrimaryMenu', 'depth' => 0) ); ?>

輸出結(jié)果為:

< div class="menu-導航欄-container"> < ul id="menu-導航欄" class="menu"> < li id="menu-item-27" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-27">< a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁</a></li> < li id="menu-item-28" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-28">< a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >一級導航</a> < ul class="sub-menu"> < li id="menu-item-29" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-29">< a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >二級導航</a></li> < li id="menu-item-30" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-30">< a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >二級導航1</a></li> < li id="menu-item-31" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-31">< a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >二級導航2</a></li> </ul> </li> </ul> </div>

關(guān)鍵詞標簽: 建站 自定義 如何使用

聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-07-23 ,文章wordpress自定義導航菜單如何使用?,建站文章主要講述自定義,如何使用,建站網(wǎng)站建設(shè)源碼以及服務器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_34945.html

我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計制作搭建開發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開發(fā)案例,網(wǎng)站推廣技術(shù)服務。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 洪雅县| 山西省| 开平市| 潮安县| 济宁市| 安龙县| 蒙城县| 中方县| 陇川县| 黄龙县| 福清市| 故城县| 台北市| 区。| 大同县| 定陶县| 辽宁省| 呼图壁县| 小金县| 四平市| 大荔县| 华安县| 乐都县| 高密市| 城固县| 留坝县| 莎车县| 武邑县| 克山县| 含山县| 西昌市| 长白| 宁南县| 五华县| 双柏县| 昆明市| 泌阳县| 上饶市| 苏尼特右旗| 呈贡县| 东乡县|