• I am looking to set it up so that my archives can display all posts within a certain category that are tagged with a specific tag. Is this possible by default, and if not, does anyone know a way to achieve it?

    Thank you in advance for all of your helpful replies ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Okay, to do that with the WordPress Default theme, assuming the category you want to do that with is category ID 7 and the tag is “tag1”.

    Save this code as wp-content/themes/default/category-7.php

    <?php
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    <?php
    query_posts($query_string . '&tag=tag1+tag1');
    ?>
    
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    
    			</div>
    		<?php endwhile; ?>
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    	<?php else : ?>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.
    
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    <?php //} 	?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Review
    Template Hierarchy
    Stepping Into Template Tags
    Stepping Into Templates

    Thread Starter Lars-Christian

    (@larscsim)

    Thanks for the help. I assume that this means that I actually have to create a new template for each tag within each of the categories, and that there is no easier of doing it?

    To give you an idea of what I’m working with: I have a music blog where I use tags to mark which band the posts are about, and I would like to in the archives not only all posts about that band (tag), but also all posts about that band (tag) in a certain category.

    Obviously the proposed solution would be inconvenient, as we are adding new bands (tags) all the time and we need it to be automated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is this archive function possible to achieve?’ is closed to new replies.