WordPress.org

Ready to get started?Download WordPress

Forums

[closed] How to exclude category from loop (11 posts)

  1. core-basic
    Blocked
    Posted 1 year ago #

    I've had a read through out the codex, and so far nothing works. How can I exclude a category from my loop?

    [moderator:
    @core-basic - as your topic got hijacked and needed to be closed, please start a new topic and add more details - thanks]

  2. keesiemeijer
    moderator
    Posted 1 year ago #

  3. alchymyth
    Forum Moderator
    Posted 1 year ago #

  4. dopple-topple
    Blocked
    Posted 1 year ago #

    Alchymyth. He clearly said that would not work and he is right. The documentation found at the link you provided says to use

    cat with a negative ID number. This does not work.

    You've got to use post__not_in see

    http://codex.wordpress.org/Class_Reference/WP_Query

    something like this would work.

    $args = array( 'paged' => 'paged', 'post__not_in'=>get_option('sticky_posts') );
    query_posts( $args ); while (have_posts()) : the_post(); ?>
  5. alchymyth
    Forum Moderator
    Posted 1 year ago #

    @dopple-topple

    please read the topic's title and main question: 'exclude a category from the loop'

    this is not about sticky posts.

  6. dopple-topple
    Blocked
    Posted 1 year ago #

    Well I didn't realize that sticky posts must be handled differently because the codex did not specify that. So to take what you said out of context.. If a post is a member of an excluded category bu that post is sticky it will not be excluded but the others will.Is that correct?

    (If any regular member wrote a post like the one above they would be blocked instantly, and you know that.)

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    @dopple-topple: I strongly recommend that you read the forum's rules before posting again.

  8. dopple-topple
    Blocked
    Posted 1 year ago #

    Okay, so sticky posts should not be handled differently? Was my statement incorrect?

    "If a post is a member of an excluded category but that post is sticky it will not be excluded but the others will."

    Is that incorrect?

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    please read the topic's title and main question: 'exclude a category from the loop'

    this is not about sticky posts.

  10. dopple-topple
    Blocked
    Posted 1 year ago #

    Yes, but the discussion has led to another question. If you read my post above it does include an inquiry over excluding categories and it's limits.

    "If a post is a member of an excluded category but that post is sticky it will not be excluded but the others will."

    There is a question in there about excluding categories and when and when not it will work.

    So if you are excluding a specific category and you post a stick post into this category the fact that it is a sticky post excludes it from being excluded in the loop? Right or wrong?

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    As per the Forum Welcome, if you have another question, please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.