title: Main loop isn't working on single.php. Wordpress
body: <p>I'm new to Wordpress and struggling to get to grips with it. On single.php i have the main loop that is suposed to show the content of a specific post, and on the same page i also run an additional loop that iterates through the posts of specific category and displays them one by one in the sidebar. The problem is: if i delete the sidebar area - everytithgs works perfectly; however if the sidebar loop is on - the main loop goes insane and always displays the latest post instead of doing her work and showing the content of the post i clicked on index.html. My sidebar loop:</p>
  <pre><code>&lt;div class=&quot;sidebar-left&quot;&gt;
                      &lt;div class=&quot;content-wrapper-left&quot;&gt;
  
                          &lt;div class=&quot;sidebar-news-block&quot;&gt;
                              &lt;?php $posts = get_posts (&quot;category=plots&amp;orderby=date&amp;numberposts=10&quot;); ?&gt;
  
                              &lt;div class=&quot;sidebar-header&quot;&gt;
                                  &lt;h3&gt;Новости&lt;/h3&gt;
                              &lt;/div&gt;
  
                              &lt;?php if ($posts) : ?&gt;
                                  &lt;?php foreach ($posts as $post) : setup_postdata ($post); ?&gt;
  
                                      &lt;div class=&quot;sidebar-news-block-card&quot;&gt;
                                          &lt;div class=&quot;sidebar-news-block-card-title&quot;&gt;
                                              &lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;?php the_title() ?&gt;&lt;/a&gt;
                                          &lt;/div&gt;
  
                                          &lt;div class=&quot;sidebar-news-block-card-publication_date&quot;&gt;
                                              &lt;span&gt;&lt;?php echo get_the_date()?&gt;&lt;/span&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
  
                                  &lt;?php endforeach; ?&gt;
                              &lt;?php endif; ?&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  <p>My main loop</p>
  <pre><code>                    &lt;div class=&quot;content-area&quot;&gt;  
                      &lt;div class=&quot;narrow-container-right&quot;&gt;                
                          &lt;?php while ( have_posts() ) : the_post(); ?&gt;
                              &lt;div class=&quot;content-area-post&quot;&gt;
                                  &lt;div class=&quot;content-area-post-content&quot;&gt;
                                      &lt;div class=&quot;content-area-post-information-block&quot;&gt;
                                          &lt;div class=&quot;content-area-post-information-block-title&quot;&gt;
                                              &lt;h3&gt;&lt;?php the_title() ?&gt;&lt;/h3&gt;
                                          &lt;/div&gt;
  
                                          &lt;div class=&quot;content-area-post-informatioin-block-publication_date&quot;&gt;
                                              &lt;span&gt;12 jay, 16:56&lt;/span&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class=&quot;content-area-post-image&quot;&gt;
                                          &lt;?php if (the_post_thumbnail()) : ?&gt;
                                              &lt;?php the_post_thumbnail() ?&gt;
                                          &lt;?php endif ?&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class=&quot;content-area-post-body&quot;&gt;
                                          &lt;article&gt;
                                                  &lt;?php the_content(); ?&gt;                         
                                          &lt;/article&gt;
                                      &lt;/div&gt;
  
  
                                  &lt;/div&gt;
                              &lt;/div&gt;      
                          &lt;?php endwhile ?&gt;                   
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  <p>I've alreadu tried replacing while with foreach and vice-versa, removing the loop at all and , adding wp_reset_postdata(), checking for syntax mistakes etc. I'm russian, so there can be some grammatic mistakes.</p>