WordPress.org

Support

Support » How-To and Troubleshooting » How to display archive results from one category?

How to display archive results from one category?

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    @esmi

    Forum Moderator

    I really appreciate the help. I tried to filter it using query posts but the problem is my results don’t display monthly results anymore, they display all the posts under this category.

    This is the code I have in my archive.php file. When you hit a month link, for example march, the results show all the posts under the blog category from few months.

    http://www.unlockingthebible.com/blog/

    <?php query_posts('cat=18'); ?>
    <?php while (have_posts()) : the_post(); ?>
    		<div <?php post_class() ?> id="post">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title() ?></a></h2>
    				<div class="post-info"><?php the_time('F jS, Y') ?></div>
    				<?php the_content_limit(300, ""); ?>
    				<div class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e("read more"); ?></a></div>
    
    		</div>
    <?php endwhile; ?>
    esmi

    @esmi

    Forum Moderator

    The custom query <?php query_posts('cat=18'); ?> is asking for a display of all posts in Category 18. If you want to restrict the display to posts in category 18 from a certain time period, you’d need to add a time parameter to your query.

    Wow, that’s really exciting stuff. I think this would work but I am using <?php wp_get_archives('type=monthly&limit=4'); ?> which dynamically displays months.

    Is there a way to use <?php wp_get_archives('type=monthly&limit=4'); ?> with time parameters in query_posts.

    If I add time now, no matter what I click it will display always results from what I specify in time parameters.

    So, my thinking is to hard-code links for months instead of using wp_get_archives and use some kind of conditional statement in my archive.php to display results based on what was clicked.

    esmi

    @esmi

    Forum Moderator

    Is there a way to use <?php wp_get_archives(‘type=monthly&limit=4’); ?> with time parameters in query_posts.

    No – sorry 🙁

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display archive results from one category?’ is closed to new replies.
Skip to toolbar