How to list articles by year based on url?
Hie all, I am trying to list posts by year based on the provided url (for example: wordpressite.com/2004 - this should list all articles created in 2004), unfortunately all suggested methods from previous solutions solve the problem if the year to be queried is given.
I tried creating the year.php file suggested in the wordpress hierarchy as well as date.php, but the_loop() just gives everything, not listing articles from the specific year.
?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();
?
And this is the individual article I would like to have
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"
divp 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';
}
?
divh4 class="archive-card-title"b?php the_title(); ?/b/h4/div
/div
/a
/div
I am still very new to wordpress, would appreciate any help.
wp_get_archives('type=yearly')
The documentation does not state how I can use my article structure mentioned above.
Topic archive-template wp-get-archives loop theme-development Wordpress
Category Web