3
我一直在長時間的谷歌搜索試圖找到解決方案...我正在創建一個使用WordPress安裝控制內容的CV經理主題。我已設法組織所有WP類別的帖子,但也希望在年度分組中列出這些帖子。目前,我有這樣的:按類別和年份排序的WordPress帖子
<?php // Categories
$cvm_cat_args = array('orderby' => 'name', 'order' => 'ASC');
$categories = get_categories($cvm_cat_args); ?>
<?php foreach($categories as $category) : ?>
<?php // Posts in category
$cvm_post_args = array('showposts' => -1, 'category__in' => array($category->term_id), 'caller_get_posts'=>1, 'order' => 'ASC');
$posts = get_posts($cvm_post_args); ?>
<?php if ($posts) : ?>
<h1><?php echo $category->name ?></h1>
<?php foreach($posts as $post) : ?>
<?php setup_postdata($post); ?>
<h3><?php the_title(); ?></h3>
<small><?php the_time(); ?></small>
<?php the_excerpt() ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
我卡如何在類別中的顯示順序一年的職位上,使得輸出將是這樣的:
<h1>Category Name 1</h1>
<h2>2010</h1>
<h3>Post name 1</h3>
<p>Excerpt...</p>
<h3>Post name 2</h3>
<p>Excerpt...</p>
<h2>2009</h1>
<h3>Post name 3</h3>
<p>Excerpt...</p>
<h3>Post name 4</h3>
<p>Excerpt...</p>
<h1>Category Name 2</h2>
etc
任何幫助將是強烈地讚賞。
謝謝!