Wordpress製作sidebar.php

來源:互聯網
上載者:User

標籤:

調用

在首頁以下方法可以調用模板中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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.