• Resolved lelandmcfarland

    (@lelandmcfarland)


    I’m having a bit of trouble with post__not_in option for the query_posts function in WordPress MU. I collect an array of post ids and then use that array in the function but it does not work. The posts that I want excluded still show up. Here is my code:

    $ps = query_posts(array('cat'=>'-19', 'showposts'=>'4', 'post__not_in'=> $displayed_posts ));

    When I print out the array of ids, this is what I get:

    Array
    (
        [0] => 12875
        [1] => 12870
        [2] => 12860
        [3] => 12743
        [4] => 12480
        [5] => 12134
    )

    Does anyone know if MU has any problems with post__not_in?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Where are you defining $displayed_posts?

    Thread Starter lelandmcfarland

    (@lelandmcfarland)

    I am setting $displayed_posts right above that function. What I am doing is that I am creating a home page that fist display the most recent 6 articles from every blog. As I am displaying those articles, I am taking their post ID and entering it into that array.

    $displayed_posts[] = $post->ID;

    I then want to go through every section and display the next 4 articles. I want to exclude any post that I have already displayed. No need for duplicate links on the same page.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The problem is you’re crossing multiple tables to get the content, though. Unless you’re using the Sitewide Tag Pages plugin to aggregate.

    Thread Starter lelandmcfarland

    (@lelandmcfarland)

    That was it. I do have Sitewide Tag Pages installed on the site and I was trying to exclude the ids for the post in the blog set up by Sitewide instead of the original blog post’s ID. Once I figured that out is was easy to get the correct IDs and exclude them. Thank you for all the help. sorry about the newbish questions, I just inherited the site a few months ago and I’m still learning all of the ins and outs of this installation of WordPress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘post__not_in not working for query_posts in wpmu’ is closed to new replies.