WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Exclude Category (8 posts)

  1. cjscrofani
    Member
    Posted 3 years ago #

    On this page: http://deweesereport.com/report-archive

    I would like to exclude a category, how would I do that with this code?

    <div id="content">
    
    <ul><?php cat_and_posts(); ?></ul>
     	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Thanks in advance for any help!

    CJ Scrofani
    cj (at) golddustweb dot com

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try:

    <div id="content">
    <ul><?php cat_and_posts(); ?></ul>
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
        'cat' => -4,
        'paged' => $paged
    );
    query_posts($args);
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    where 4 is the id of the category you want to exclude.
    http://codex.wordpress.org/Function_Reference/query_posts

  3. cjscrofani
    Member
    Posted 3 years ago #

    That placed a bunch of posts at the button of the page and the category I wanted removed was still there.

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Do you have another Loop running in that page?

  5. cjscrofani
    Member
    Posted 3 years ago #

    Here's the full page template code:

    <?php
    /*
    Template Name: archive
    */
    ?>
    
    <?php get_header(); ?>
    
      <div id="content">
    <ul><?php cat_and_posts(); ?></ul>
     	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
     <div class="post">
    
          <div class="entry">
        <?php the_content('Read the rest of this entry &raquo;'); ?>
          </div>
        </div>
    
    <?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		<p>Sorry, but you are looking for something that isn't here.</p>
    
    	<?php endif; ?>
    
      </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  6. esmi
    Forum Moderator
    Posted 3 years ago #

    What's in the cat_and_posts() function?

  7. cjscrofani
    Member
    Posted 3 years ago #

    I wasn't the original person to set up the site so I'm not sure. Would the AVH Extended Category plugin have anything to do with that?

  8. Gisha James
    Member
    Posted 3 years ago #

    Check functions.php of your theme and see a function like cat_and_posts exist there.

  9. cjscrofani
    Member
    Posted 3 years ago #

    Resolved the problem in the functions.php file. Thank you everyone!

Topic Closed

This topic has been closed to new replies.

About this Topic