Note that there are some explanatory texts on larger screens.

plurals
  1. POWordPress Loop Error
    primarykey
    data
    text
    <p>First let me say that I have been working on this issue for about 2 weeks and I have looked all over the place for an answer. Ive gone to various forums, blogs, the WordPress Codex and just about any and all places I could find. I still cannot get this to work properly. As a last resort I am coming here to see if maybe someone can assist me with it.</p> <p>My issue is this. I am building a free Wordpress theme, <a href="http://wp-awesome.themeawesome.com" rel="nofollow">http://wp-awesome.themeawesome.com</a>. I will be submitting it to the WordPress Theme Repository and hopefully get it hosted so people can download it. One of the requirements is that a theme cannot generate any errors. Everything is working perfectly and there are no errors except one. I get the following error message when I go to a second page:</p> <p>*<strong>Notice: Undefined variable: do_not_duplicate in /--/--/--/--/--/--/wp-awesome/index.php on line 68*</strong></p> <p>As you can see on the front page there is a featured post slider. This slider is will display posts that are tagged "featured". I am using the following code for this specific query:</p> <pre><code> &lt;?php $mytag = mytheme_option( 'featured_tag' ); $thecount = mytheme_option( 'featured_count' ); $my_query = new WP_Query("tag=$mytag&amp;showposts=$thecount"); while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $do_not_duplicate[] = $post-&gt;ID; ?&gt; // post stuff here &lt;?php endwhile; ?&gt; </code></pre> <p>Now obviously on the home page I do not want the posts that are displaying in the slider to display on the front page in the regular loop below it. So i found the following code that seems to work great:</p> <pre><code> &lt;?php if (is_home()) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'post__not_in' =&gt; $do_not_duplicate, 'paged' =&gt; $paged )); } if (have_posts()) : while (have_posts()) : the_post(); ?&gt; // post stuff &lt;?php endwhile; ?&gt; </code></pre> <p>the only problem is when you click on another page at the bottom the error shows up:</p> <p>*<strong>Notice: Undefined variable: do_not_duplicate in /--/--/--/--/--/--/wp-awesome/index.php on line 68*</strong></p> <p>I know the error is appearing because when you go to a second or third page, there is nothing defining the do_not_duplicate param. Any ideas how to fix this?</p> <p>Any help is greatly appreciated and I thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload