• Hi everyone,

    Here is a code that i have and for some reason my results are appearing in the following order:
    1st Page – 1 result
    2nd Page – 2 results
    3rd Page – 3 results

    Basically i want to exclude categories 9 and 17. Any clue as to why this could be happening.
    P.s: i dont want to use plugins

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (in_category('9')) continue; ?>
    
    <?php if (in_category('14')) continue; ?>
    
    <?php the_title(); ?><br /><br />
    
    <?php endwhile;endif;?>
    
    <?php next_posts_link('&laquo; Old Updates') ?>
    
    <?php previous_posts_link('Latest Updates &raquo;') ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, see if this works for you:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $s = get_query_var('s');
    query_posts("s=$s&cat=-9,-14&paged=$page");
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_title(); ?><br /><br />
    <?php endwhile;endif;?>
    <?php next_posts_link('&laquo; Old Updates') ?>
    <?php previous_posts_link('Latest Updates &raquo;') ?>

    Thread Starter 775749

    Hey rmk80,

    your a freakin genius!

    Ive been trying to fix this for the past couple of days!

    5 Stars for you mate!

    @rmk80: If i want to exclude all pages and some categories from search results then what i must do? Do you know a solution?

    awesome! Just what I needed! Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude Categories in Search Results’ is closed to new replies.