Skip to content

Instantly share code, notes, and snippets.

  • Save senooat/735e3e92f0608ea6b71145c50b561ed9 to your computer and use it in GitHub Desktop.
Save senooat/735e3e92f0608ea6b71145c50b561ed9 to your computer and use it in GitHub Desktop.
WordPressのサイドバーにカテゴリー、最近の記事、月別アーカイブなどよくあるコンテンツを表示するテンプレートタグまとめ
/*-----------------------------------
カテゴリー
-----------------------------------*/
<h2>カテゴリー</h2>
<ul>
<?php wp_list_categories( 'title_li=&show_count=1&hide_empty=0' ); ?>
</ul>
/*-----------------------------------
最近の記事(5件表示)
-----------------------------------*/
<h2>最近の記事</h2>
<ul>
<?php wp_get_archives( 'type=postbypost&limit=5' ); ?>
</ul>
/*-----------------------------------
月別アーカイブ
-----------------------------------*/
<h2>月別アーカイブ</h2>
<ul>
<?php wp_get_archives(); ?>
</ul>
/*-----------------------------------
月別アーカイブ(ドロップダウン形式)
-----------------------------------*/
<h2>月別アーカイブ</h2>
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?>
</select>
/*-----------------------------------
カレンダー
-----------------------------------*/
<h2>カレンダー</h2>
<?php get_calendar(); ?>
/*-----------------------------------
タグクラウド
-----------------------------------*/
<h2>タグクラウド</h2>
<?php wp_tag_cloud(); ?>
/*-----------------------------------
検索フォーム
-----------------------------------*/
<?php get_search_form(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment