WordPress.org

Forums

How to display archive results from one category? (7 posts)

  1. krystiank
    Member
    Posted 5 years ago #

    I have two main categories on my site and would like to know how to filter archive result to show results only for particular category.

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

  2. esmi
    Forum Moderator
    Posted 5 years ago #

  3. krystiank
    Member
    Posted 5 years ago #

    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.

  4. krystiank
    Member
    Posted 5 years ago #

    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; ?>
  5. esmi
    Forum Moderator
    Posted 5 years ago #

    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.

  6. krystiank
    Member
    Posted 5 years ago #

    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.

  7. esmi
    Forum Moderator
    Posted 5 years ago #

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

    No - sorry :-(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.