Forums

Exclude Sticky Posts and Categories from the Loop (5 posts)

  1. duanecilliers
    Member
    Posted 1 year ago #

    Hey guys.

    I'm trying to exclude sticky posts and a certain category from the loop in a blog I'm working on.

    I have two snippets of code that work well individually, but I can't figure out how to combine them. Any help is appreciated.

    This excludes sticky posts from the loop...
    <?php query_posts(array("post__not_in" =>get_option("sticky_posts"))); ?>

    ... and this excludes a specific category from the loop...
    <?php query_posts($query_string . '&cat=-8'); ?>

    How would I go about combining the two to exclude both sticky posts and category ID 8???

    Thanks for taking the time to read this.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    <?php query_posts($query_string . '&cat=-8&post__not_in='. get_option('sticky_posts')); ?>

  3. duanecilliers
    Member
    Posted 1 year ago #

    Thank you for your input @esmi, but your code doesn't quite work.

    It returns these errors...

    Warning: array_map() [function.array-map]: Argument #2 should be an array in /usr/home/adamlang/public_html/cpdc/wp-includes/query.php on line 2104
    
    Warning: implode() [function.implode]: Invalid arguments passed in /usr/home/adamlang/public_html/cpdc/wp-includes/query.php on line 2104
    
    Warning: array_diff() [function.array-diff]: Argument #2 is not an array in /usr/home/adamlang/public_html/cpdc/wp-includes/query.php on line 2660

    Do you or anyone else by any chance have any other ideas??? I'm kinda desperate here and I'm by far a PHP guru, so any input is greatly appreciated.

    Thanks again.

  4. 123milliseconds
    Member
    Posted 1 year ago #

    HI

    Your errors does not refer to esmi's code

    Please paste the file you changed at http://wordpress.pastebin.com/

    Select PHP syntax highlighting so we can easily read the code

    Post the link you get at pastebin here, so that we can look at it.

    --

    Posting the backup before you changed it will help too

  5. duanecilliers
    Member
    Posted 1 year ago #

    Here's the file I edited: http://pastebin.com/GjJ2R854

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic