Excluding multiple posts from a widget
-
Hello,
I have a custom skin on my wordpress blog which has two containers for posts. My aim is to query the same categories but not show posts pulled in the first container call.Here is a exclude code i added in the first container
<?php $getposts = new WP_query(); $getposts->query('showposts='.$options['leftpostnum'].'&cat='.$section); ?> <?php global $wp_query; $wp_query->in_the_loop = true; ?> <?php while ($getposts->have_posts()) : $getposts->the_post(); ?> <?php $do_not_duplicate[] = $post->ID; ?> .................... Come html Code there ..................... <?php endwhile; ?>Basically $do_not_duplicate is an array with all post id’s
Now in the second block i am adding this to the query using the wordpress function post__not_in
<?php $getposts = new WP_query(); $getposts->query('showposts=10&offset='.$options['rightpostnum'].'&cat='.$section.'&post__not_in='.$do_not_duplicate); ?> <?php global $wp_query; $wp_query->in_the_loop = true; ?> <?php while ($getposts->have_posts()) : $getposts->the_post(); ?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?>Unfortunately that doesn’t seem to work. This is the error i get.
Warning: array_map() [function.array-map]: Argument #2 should be an array in /home/xyz/public_html/wp-includes/query.php on line 1725
Warning: implode() [function.implode]: Invalid arguments passed in /home/xyz/public_html/wp-includes/query.php on line 1725
The wordpress verion is 2.7.1.
I used vardumps to check and the array is there before second query executes. However in the query file throws an error.
Any help.
Thanks
The topic ‘Excluding multiple posts from a widget’ is closed to new replies.