WordPress.org

Ready to get started?Download WordPress

Forums

Yearly archive by Category (2 posts)

  1. caledoniaman
    Member
    Posted 1 year ago #

    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:-
    http://img845.imageshack.us/img845/1999/s392341525websitehomeco.png

    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.

  2. potentweb
    Member
    Posted 1 year ago #

    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();
    	the_title();
    	echo '<div class="entry-content">';
    	the_content();
    	echo '</div>';
    endwhile;

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

Topic Closed

This topic has been closed to new replies.

About this Topic