要實現的如下功能,在頁面上添加一個文章目錄:
步驟:






<?php get_header(); ?> --------這里是頭部文件,獲取菜單等
<div id="container"> ---------這里包含的是主頁面內容
<div id="content" role="main">
<?php get_template_part( 'loop', 'index' ); ?> -------------獲取文章內容
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?> -------這句用來獲取你放在側邊欄的內容,如果你上一步把文章目錄放在了側邊欄里,這里就能獲取到
<?php get_footer(); ?> ----------頁腳內容
/*
LAYOUT: Two columns
DESCRIPTION: Two-column fixed layout with one sidebar right of content
*/
#container {
float: right; ----------------這里寫明container是居右
margin: 0 -240px 0 0;
width: 100%;
}
#content {
margin: 0 280px 0 20px;
}
#primary,
#secondary {
float: left; --------------------------這里說明文章目錄所在的居左,如果需要改變,left/right互換
overflow: hidden;
width: 220px;
}
#secondary {
clear: left; -------------------------這里說明文章目錄所在的居左,如果需要改變,left/right互換
}
#footer {
clear: both;
width: 100%;
}

function wp_list_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'show_option_none' => __('No categories'),
'orderby' => 'name', 'order' => 'ASC',
'style' => 'list',
'show_count' => 0, 'hide_empty' => 1,
'use_desc_for_title' => 1, 'child_of' => 0,
'feed' => '', 'feed_type' => '',
'feed_image' => '', 'exclude' => '',
'exclude_tree' => '', 'current_category' => 0,
'hierarchical' => true, 'title_li' => __( 'Categories' ),
'echo' => 1, 'depth' => 0, -----------------------------這里設置為1,可以默認顯示為1級目錄
'taxonomy' => 'category'
);
