调用
在主页以下方法可以调用模板中sidebar.php的内容
<?php get_sidebar(); ?>
判断是否自定义sidebar侧边栏:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('First_sidebar') ) : ?>
.....
<?php endif; ?>
分类目录,使用wp_list_categories>>获得分类所有信息,或使用get_categories>>
<ul>
<?php
$args= array(
'depth'=>1,
'orderby'=>id
);
wp_list_categories( $args ); ?>
</ul>
最新文章:
<h4>最新文章</h4>
<ul>
<?php
$posts = get_posts('numberposts=6&orderby=post_date');
foreach($posts as $post) {
setup_postdata($post);
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
$post = $posts[0];
?>
</ul>
标签:
<h4>标签云</h4>
<p><?php wp_tag_cloud('smallest=8&largest=22'); ?></p>
文章归档:
<h4>文章存档</h4>
<ul>
<?php wp_get_archives('limit=10'); ?>
</ul>