Hie all,我正在尝试根据提供的url按年份列出帖子(例如:wordpressite.com/2004-这应该列出2004年创建的所有文章),不幸的是,如果给出了查询年份,以前解决方案中的所有建议方法都可以解决问题。
我试着创造这一年。wordpress层次结构中建议的php文件以及日期。php,但\\u loop()只提供了所有内容,没有列出特定年份的文章。
<?php
query_posts(\'posts_per_page=10\');
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( \'archive-content\', get_post_format() );
endwhile; endif;
wp_reset_query();
?>
这是我想要的一篇文章<div class="row" style="margin-top: 15px;">
<a href="<?php the_permalink() ?>">
<div class="col col-sm-3 remove-left-margin">
<?php $url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), \'thumbnail\' ); ?>
<img src="<?php echo $url ?>" class="archive-card-image" />
</div>
<div class="col col-sm-9">
<div><p class="archive-card-date"><?php the_date(); ?></p></div>
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo \'<div class="card-article-tag"><a class="archive-card-topic" href="\' . esc_url( get_category_link( $categories[0]->term_id ) ) . \'">\' . esc_html( $categories[0]->name ) . \'</a></div>\';
}
?>
<div><h4 class="archive-card-title"><b><?php the_title(); ?></b></h4></div>
</div>
</a>
</div>
我对wordpress还是很陌生,如果有任何帮助,我将不胜感激。wp_get_archives(\'type=yearly\')
文档中没有说明如何使用上面提到的文章结构。