首页 > Web开发 > 详细

Wordpress制作sidebar.php

时间:2016-09-17 00:35:58      阅读:222      评论:0      收藏:0      [点我收藏+]

调用

在主页以下方法可以调用模板中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>

 

Wordpress制作sidebar.php

原文:http://www.cnblogs.com/tinyphp/p/5876106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!