最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

WordPress中用于創(chuàng)建以及獲取側(cè)邊欄的PHP函數(shù)講解

 更新時(shí)間:2015年12月29日 14:35:50   作者:斌果  
這篇文章主要介紹了WordPress中用于創(chuàng)建以及獲取側(cè)邊欄的PHP函數(shù)講解,分別為register_sidebar()函數(shù)和get_sidebar()的使用,需要的朋友可以參考下

register_sidebar()(創(chuàng)建側(cè)邊欄)
建立一個(gè)側(cè)邊欄,用來(lái)放置小工具。這個(gè)函數(shù)使用的時(shí)候請(qǐng)放在一個(gè)函數(shù)里,掛載到 “widgets_init” 鉤子。

用法

register_sidebar( $args );

參數(shù)

$args

(字符串 | 數(shù)組)(可選)要?jiǎng)?chuàng)建的側(cè)邊欄的參數(shù)。

默認(rèn)值:

$args = array(
  'name'     => __( 'Sidebar name', 'theme_text_domain' ),
  'id'      => 'unique-sidebar-id',
  'description'  => '',
  'class'     => '',
  'before_widget' => '<li id="%1" class="widget %2">',
  'after_widget' => '</li>',
  'before_title' => '<h2 class="widgettitle">',
  'after_title'  => '</h2>'
);

數(shù)組參數(shù)介紹:

  • name:側(cè)邊欄名稱
  • id:側(cè)邊欄 ID,必須為小寫,默認(rèn)為遞增的數(shù)組 ID
  • description:側(cè)邊欄描述
  • class:給其中的小工具的額外 class
  • before_widget:里邊的小工具的開頭 Html 代碼
  • after_widget:里邊的小工具的末尾的 Html 代碼
  • before_title:里邊的小工具的標(biāo)題的開頭 Html 代碼
  • after_title:里邊的小工具的標(biāo)題的末尾的 Html 代碼

例子

register_sidebar( array(
  'name'     => __( '右邊的側(cè)邊欄' ),
  'id'      => 'sidebar-1',
  'description' => __( '右側(cè)邊欄的小工具。' ),
  'before_title' => '<h3 class="title">',
  'after_title' => '</h3 class="title">',
));

其它

該函數(shù)位于:wp-includes/widgets.php

get_sidebar()(獲取側(cè)邊欄)
get_sidebar() 用來(lái)引入側(cè)邊欄模板。如果指定名稱則引入當(dāng)前主題根目錄的 sidebar-{name}.php 文件,不指定則引入當(dāng)前主題根目錄的 sidebar.php 文件,如果文件不存在則引入 wp-includes/theme-compat/sidebar.php 文件。

用法

get_sidebar( $name );

參數(shù)

$name

(字符串)(可選)引入模板的名稱,如果指定則引入當(dāng)前主題根目錄的 sidebar-{$name}.php 文件。

默認(rèn)值:None

例子

下邊的代碼將引入當(dāng)前主題根目錄的 sidebar.php 文件:

<?php get_sidebar(); ?>

下邊的代碼將引入當(dāng)前主題根目錄的 sidebar-left.php 文件:

<?php get_sidebar( 'left' ); ?>

下邊的例子分別引入了左側(cè)邊欄(sidebar-left.php)和右側(cè)邊欄(sidebar-right.php):

<?php get_header(); ?>
<?php get_sidebar( 'left' ); ?>

內(nèi)容內(nèi)容

<?php get_sidebar( 'right' ); ?>
<?php get_footer(); ?>

其它

此函數(shù)位于:wp-includes/general-template.php

相關(guān)文章

最新評(píng)論

清镇市| 马公市| 施甸县| 军事| 色达县| 赣榆县| 锦州市| 贵港市| 泽库县| 金坛市| 泌阳县| 蓬安县| 德州市| 西平县| 永德县| 夏津县| 鞍山市| 林西县| 涿州市| 仁怀市| 琼结县| 大洼县| 芜湖市| 鄂伦春自治旗| 长子县| 彝良县| 益阳市| 喀喇沁旗| 淮阳县| 喜德县| 青川县| 巴南区| 祥云县| 南平市| 老河口市| 腾冲县| 太谷县| 木兰县| 万州区| 客服| 商水县|