ThemeShaper Forums » Thematic


exclude certain categories in archive page

(6 posts)
  • Started 9 years ago by sathiz
  • Latest reply from sathiz
  • This topic is not resolved
  1. sathiz

    I have a blog page that excludes certain categories. I used the following code in the blog template:
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query = new WP_Query();
    'cat' => '-12,-15',
    'paged'=> $paged));
    $more = 0;
    on the same page, i have a sidebar with Archives list link. Eg: March 2012, February 2012.
    When i click on the link, it shows all the posts including the categories that i don't want. i.e cat 12 and 15.
    I tried putting the above code in the Archive.php (template page) but it didn't work.
    Can someone help me with this?


    Posted 9 years ago #
  2. ok, glad you got a new thread going. where DO you want this category's posts allowed to show?

    your question isn't thematic-related, but i suspect that pre_get_posts() will be the filter you need to target, much like i suggested in the other post.

    also like i suggested in the other post, using a page template for the blog is being deprecated by thematic.

    Posted 9 years ago #
  3. sathiz

    thanks! Category_exclusion did help not to display the excluded categories in the blog page and the archive page. But it also didn't show up other pages where i want those categories to be listed.
    Here is the code i had:
    set_query_var('cat','-12,-15' );

    Posted 9 years ago #
  4. that can't possibly be all the code you used, no wonder it didn't do anything. where did you put that? and YES, i can confirm that the code in the codex DOES work to exclude categories (at least from the index loop)... your conditional logic might need tweaking in addition to your actually categories.

    Posted 9 years ago #
  5. sathiz

    never mind. got it added && !is_category() to if.

    Posted 9 years ago #
  6. sathiz

    oh ya! that's not the only code. i did have add_filter('pre_get_posts', 'function_name'); :)
    Thank you for your quick responses.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.