do_not_duplicate for a widget
-
Hello everybody !
i’m trying to create my first theme, and experiencing problems with creating a widget and duplicated post…
i found the other posts about this subject but can’t find out what’s happenig to me… so here it is..
i have one slider taking the 3 last posts and would like to have a widget with the other posts but it looks like my $do_not_duplicate array does’nt exist yet in the widget !
here is the simple code :
in index.php i have :<?php //Loop 1 $loop1 = new WP_query('cat=0&showposts=2'); if($loop1->have_posts()) : while($loop1->have_posts()) : $loop1->the_post(); $do_not_duplicate[] = $post->ID; the_title(); echo "<br>"; endwhile; endif; ?>
and in my widget :
<?php //Loop 2 $loop2 = new WP_query('order=DESC&showposts=100'); while($loop2->have_posts()) : $loop2->the_post(); if(in_array($post->ID, $do_not_duplicate)) continue; update_post_caches($posts); ?> <br /> <?php echo the_title(); endwhile; ?>
and the result is here…
Warning: in_array() expects parameter 2 to be array, null given inthe do_not_duplicate doesn’t exist in the widget…
any advice about what i did wrong ?
thanks…
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘do_not_duplicate for a widget’ is closed to new replies.