Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In the script below, the post__not_in argument does not appear to be working unless I hardcode the post ids inside the array(). Anything stand out?

If an item is in the category, but also in the post__not_in, what get's precedent?

get_option('sticky_posts') is a single item array with var_dump = array(1) { [0]=> int(6) }

$myposts = get_posts(
                    array('cat' => "$cat,-$catHidden", 
                        'post__not_in' => array($post->ID, get_option('sticky_posts')), 
                        'numberposts' => 10;
                        )
                    );
            foreach($myposts as $idx=>$post){//do something}
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

try:

$not_in = get_option('sticky_posts');
$not_in[] = $post->ID;
$myposts = get_posts(
                    array('cat' => "$cat,-$catHidden", 
                        'post__not_in' => $not_in, 
                        'numberposts' => 10;
                        )
                    );
foreach($myposts as $idx=>$post){//do something}

hope this helps

share|improve this answer
    
To clarify the original problem, the issue was with the array you were forming Scott, get_option('sticky_posts') gives you can array, so in turn your array ended up nesting another array inside it(when post__not_in only suppports using a flat array of values). This answer should solve it, so got my +1.. :) –  t31os Feb 17 '11 at 11:31
    
Thanks guys, I was thinking it was something to do with the nested array. I really appreciate the help and explanation. –  Scott B Feb 17 '11 at 13:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.