Title: template loop is accessing all posts content?
Last modified: August 19, 2016

---

# template loop is accessing all posts content?

 *  Resolved [Moodles](https://wordpress.org/support/users/moodles/)
 * (@moodles)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/template-loop-is-accessing-all-posts-content/)
 * In a custom theme, I have several page templates on which I want one category
   only to appear. The posts appear as they should, all contain lists of documents.
   However today I just discovered that when there is a link to a document that 
   is broken, the page reloads but with *ALL* the posts’ content displayed. I can’t
   show you a link the site is password-protected.
 * I think I have made a mistake with the loop but cannot figure this out.
    The 
   template is named page-projects.php.
 *     ```
       <div id="content">
   
       <?php query_posts('cat=4'); ?>
   
       <?php if(have_posts()) : ?>
   
       <?php while ( have_posts() ) : the_post() ?>
       		<div id="post-<?php the_ID() ?>" class="documents">
       			<h2 class="postTitle"><?php the_title() ?></h2>
       				<div class="postContent">
   
       				<?php the_content(); ?>
   
       				</div><!-- .postContent -->
   
       		</div><!-- .post -->
   
       <?php endwhile ?>
   
       		<div class="navigation">
       			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
       			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
       		</div>
   
       <?php endif ?>
   
       </div><!-- #content -->
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/template-loop-is-accessing-all-posts-content/#post-1566468)
 * are you using a plugin to detect broken links?
    and what is its action if a broken
   lin kis detected?
 * normally, html does not care or check if links are broken.
    there is nothing 
   in your code that would suggest that the page is reloaded on any condition.
 *  Thread Starter [Moodles](https://wordpress.org/support/users/moodles/)
 * (@moodles)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/template-loop-is-accessing-all-posts-content/#post-1566474)
 * Thanks, I just tried one and it said no broken links detected.
 * I just realized I had forgotten to upload the 404.php page.
 * So now the broken link gets to that page. However I notice that now all the menu
   links seems to want the upload folder where the missing file should be. I can’t
   get out of the 404 page unless I click on home, which is using index.php. By 
   get out of, I mean WP now thinks I’m within the uploads folder, so the menu links
   aren’t working (they are relative)/.
 * The problem isn’t the broken link; it’s what WP is doing within my loop(s) I 
   think.
 * Somehow I have done the category page templates incorrectly I think.
 *  Thread Starter [Moodles](https://wordpress.org/support/users/moodles/)
 * (@moodles)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/template-loop-is-accessing-all-posts-content/#post-1566495)
 * I’m still not sure why the all-posts-content appeared. When I did “view source”
   all the posts appeared to be within one loop?
 * As far as I can tell I am using query_posts correctly on the templates, though
   now that I’ve done all this research I may have set up this categories and templates
   in a way that was more complex than necessary. (I am not maintaining this blog,
   and tried to make things as brain-free as possible for the actual admin who knows
   nothing about HTML/CSS)
 * I have added straight URLs to the menu in the header; one thing that was happening
   is that the menu was picking up on WP’s system of putting the category into the
   path. The relative links just didn’t work with the category templates too.
 * So the blog is working correctly now, though I don’t think I answered my first
   inquiry. Thanks, Alchymyth.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘template loop is accessing all posts content?’ is closed to new replies.

## Tags

 * [custom loop](https://wordpress.org/support/topic-tag/custom-loop/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Moodles](https://wordpress.org/support/users/moodles/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/template-loop-is-accessing-all-posts-content/#post-1566495)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
