Forums

Exclude category from query_posts (18 posts)

  1. elmnt
    Member
    Posted 10 months ago #

    I'm having trouble with this, and have searched the Forum for about an hour. I see many 'similar' issues, but not this one in particular. I think my problem stems from the use of the array here (but, obviously, I'm not sure).

    I have this line of code in home.php

    <?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged' => get_query_var( 'paged' ) ) ); ?>

    I want to exclude the category with the ID '10'

    How do I edit that query_post line to accomplish this?

    Thanks!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    <?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged' => get_query_var( 'paged' ), 'cat = -10' ) ); ?>

  3. alchymyth
    The Sweeper & Moderator
    Posted 10 months ago #

  4. elmnt
    Member
    Posted 10 months ago #

    Thanks for your reply esmi, but category 10 is still showing up in the main feed when I do it that way. I think I'm getting closer, using some info from that link, alchymyth, but not quite there yet. I've excluded category 10, but now the posts are showing up in reverse order (by date, oldest to newest). So I tried this:

    <?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged' => get_query_var( 'paged' ), 'orderby' => 'date', 'order' => 'ASC', 'category__not_in' => array( 10 ) ) ); ?>

    Still not affecting the order, whether I use ASC or DESC Showing up oldest-to-newest. I'm sure I'm missing something simple?

  5. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    The main feed? Are we talking about an RSS feed or a posts page?

  6. elmnt
    Member
    Posted 10 months ago #

    Sorry, main "posts page," as in the main blog home page. I know I'm probably using incorrect terms!

  7. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Try 'order' => 'DESC'

  8. elmnt
    Member
    Posted 10 months ago #

    Yeah, I've tried both ASC and DESC in that position, but it doesn't change anything. The posts still show up oldest-to-newest. Weird.

  9. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Is this the only query on the page or do you have other loops running?

  10. elmnt
    Member
    Posted 10 months ago #

    That is the only one.

  11. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    So nothing in other template files on the same page - such as sidebar.php, header.php etc?

  12. elmnt
    Member
    Posted 10 months ago #

    No, I even did a multi-file search of all the MAIN template files, as well as the CHILD template files (which I'm working on), and that is the ONLY instance of query_posts. It appears in home.php, and nowhere else :/

  13. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Is this a custom page template?

  14. elmnt
    Member
    Posted 10 months ago #

    no, it's a standard page template, and that's the only line I've edited on that page.

  15. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    where did you download the theme from?

  16. elmnt
    Member
    Posted 10 months ago #

    It's from Theme Hybrid http://themehybrid.com/

    Maybe I should start in their Forum next, and see if I can get something there...

  17. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    I think that would be a good idea. It's a pretty complex theme and they are the experts.

  18. elmnt
    Member
    Posted 10 months ago #

    Thanks for your time and help, I appreciate it!

Reply

You must log in to post.

About this Topic

Tags