• mbond5

    (@mbond5)


    Hey Everyone,

    Below is the code on my archive.php file and what I am looking for is how to edit the code to exclude some categories from the archive as I dont need all the categories in the archive.

    All help appreciated,

    Thanks

    <?php
    /**
     * @package WordPress
     * @subpackage A Step Above
     */
    
    get_header(); ?>
    
    <div id="subnav">
    <?php do_action('wp_menubar','subtalk'); ?>
    <!-- subnav --></div>
    
    <div id="content">
    
    <div class="three-col">
    
    			<?php /* If this is a category archive */ if (is_category()) { ?>
    			<h2 class="archive_head">Entries Tagged as '<?php echo single_cat_title(); ?>'</h2>
    			<?php /* If this is a tag archive */ } elseif (is_tag()) { ?>
    			<h2 class="archive_head">Entries Tagged as '<?php echo single_tag_title() ?>'</h2>
    			<?php /* If this is a date archive */ } elseif (is_date()) { ?>
    			<h2 class="archive_head">Entries from <?php the_time('F Y'); ?></h2>
    			<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    			<h2 class="archive_head">Entries from <?php the_time('F Y'); ?></h2>
    			<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    			<h2 class="archive_head">Entries from <?php the_time('Y'); ?></h2>
    			<?php /* If this is a search */ } elseif (is_search()) { ?>
    			<h2 class="archive_head">Search Results</h2>
    			<?php } ?>
    
                <?php if (have_posts()):while (have_posts()) : the_post(); ?>
    
    			<div id="post-<?php the_ID(); ?>"  <?php post_class(); ?>>
    
    				<div class="post_content">
    				<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<div class="entry clearfix">
    					<?php the_excerpt(); ?>
    				</div>
    				</div>
    				<span class="clear"></span>
    				<div class="post_meta rounded">Posted by <a href="#"><?php the_author(); ?></a> in <?php the_category('/'); ?> / <?php comments_popup_link('No Comments.', '1 Comment', '% Comments'); ?> </div>
    
    			</div><?php /* end post */ ?>
    			<?php endwhile; ?>
    		<?php else : ?>
    			<h2 class="page_header center">Not Found</h2>
    			<div class="entry">
    				<p>Sorry, but you are looking for something that isn't here.</p>
    				<?php get_search_form(); ?>
    			</div>
    
    		<?php endif; ?>
    
    </div><!-- #content -->
    
    <?php get_sidebar(); ?>
    
    <!-- content --></div>
    
    <!-- wrapper --></div>
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Moderator t-p

    (@t-p)

    try this in your archive.php:

    Try editing archive.php and adding:

    <?php query_posts('cat=-1,-2,-3,-4');?>

    For example, the above will exclude any post that belongs to categories 1, 2, 3, 4.

    just before The Loop:
    (if ( have_posts() ) : while ( have_posts() ) : the_post();).

    Also read:
    https://codex.www.ads-software.com/Template_Tags/query_posts

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude Categories From Archive?’ is closed to new replies.