Support » Themes and Templates » Yearly archive by Category

  • I have a sidebar in my theme in which I need to display a list of content by year.

    I have three distinct categories I want to do this for.

    1. Events
    2. News
    3. Articles

    Each has it’s own distinct category, however ‘Events’ is a custom post type (to complicate matters further).

    The sidebar looks as follows:-

    I can get the yearly list to display, however clicking on any of the year links takes me to an archive page of all content for that year (Articles and News). Events don’t show in this page, presumably because they are custom posts.

    I’ve tried numerous plugins but they can’t show a category archive for Events because they are custom posts.

    End. Of. My. Tether.

Viewing 1 replies (of 1 total)
  • Create custom archive templates for your custom post type, such as single-{posttype}.php etc etc and in that template

    $args = array( 'post_type' => 'product', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    	echo '<div class="entry-content">';
    	echo '</div>';

    Where post_type is your custom post type. Modify it to suit your needs.

Viewing 1 replies (of 1 total)
  • The topic ‘Yearly archive by Category’ is closed to new replies.