• duanecilliers

    (@duanecilliers)


    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

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

    Thread Starter duanecilliers

    (@duanecilliers)

    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.

    Alwyn Botha

    (@123milliseconds)

    HI

    Your errors does not refer to esmi’s code

    Please paste the file you changed at https://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

    Thread Starter duanecilliers

    (@duanecilliers)

    Here’s the file I edited: https://pastebin.com/GjJ2R854

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude Sticky Posts and Categories from the Loop’ is closed to new replies.