• Hi,

    I have several pages on my website, which I update using blog posts.
    Depending on the category, the post turns up on the specified page.

    Posts in category News, will appear on the page News.

    However, I’d like to limit the amount of posts to the current year only.

    Anyone here that can tell me how to do this ?

    I am using a child theme of twenty eleven, the category-10.php
    (which is my news category template, directing my blog posts in category news to the news page) is set up as follows at this moment:

    <?php
    /*
    Template Name: Category-News
    */
    ?>
    
    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Used to display archive-type pages if nothing more specific matches a query.
     * For example, puts together date-based pages if no date.php file exists.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); ?>
    
    		<section id="primary">
    			<div id="content" role="main">
    
    <header class="page-header">
    					<h1 class="page-title">
    						<?php if ( is_day() ) : ?>
    							<?php printf( __( 'Daily Archives: %s', 'twentyeleven' ), '<span>' . get_the_date() . '</span>' ); ?>
    						<?php elseif ( is_month() ) : ?>
    							<?php printf( __( 'Monthly Archives: %s', 'twentyeleven' ), '<span>' . get_the_date( 'F Y' ) . '</span>' ); ?>
    						<?php elseif ( is_year() ) : ?>
    							<?php printf( __( 'Yearly Archives: %s', 'twentyeleven' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
    						<?php else : ?>
    							<?php _e( 'News', 'twentyeleven' ); ?>
    						<?php endif; ?>
    					</h1>
    				</header>
    
    		<ul class="category-10">
    
    			<?php $archive_query = new WP_Query('cat=10&showposts=1000');
    			while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
    		<h6><?php the_title(); ?><span><?php the_time('F jS, Y') ?></span></h6>
    		<?php the_content(); ?><p><em>Added by <?php the_author(); ?></em></p>
    
    			<?php endwhile; ?>
    		</ul>
    
    			</div><!-- #content -->
    		</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    In addition I’d like a yearly archive but that prooves to be very tough.
    I can get every post from every category on all the pages, but I want the older news posts to be visible only in the news page, diary on the diary page and so on…

    Website can be found here.
    http://www.fortherestless.com/login/news1

  • The topic ‘Display this year's posts only on category page’ is closed to new replies.