Title: Adding WordPress loop to a static .php file
Last modified: August 20, 2016

---

# Adding WordPress loop to a static .php file

 *  [websperations](https://wordpress.org/support/users/websperations/)
 * (@websperations)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/adding-wordpress-loop-to-a-static-php-file/)
 * Hello,
 * I just added a WordPress loop to a page on a static website.
 * The page is located at:
 * [http://protectionalarms.com/news/](http://protectionalarms.com/news/)
 * WordPress is installed at: [http://protectionalarms.com/wp](http://protectionalarms.com/wp/)
 * What I need is a next/lest button for pagination. I tried some code I found but
   it kept giving me a 404 error inside the WordPess site. I don’t want the public
   to see the WordPress site at all.
 * The loop I used is:
 *     ```
       <!-- Start the Loop. -->
        <?php query_posts('showposts=5'); ?>
   
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
         <div class="post">
   
        <!-- Display the Title as a link to the Post's permalink. -->
        <div class="title"><?php the_title(); ?></div>
   
        <!-- Display the Post's Content in a div box. -->
        <div class="entry">
          <?php the_content(); ?>
        </div>
   
         <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
       <div class="entry_date"><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></div>
   
        </div> <!-- closes the first div box -->
   
        <!-- Stop The Loop (but note the "else:" - see next line). -->
        <?php endwhile; else: ?>
   
        <!-- The very first "if" tested to see if there were any Posts to -->
        <!-- display.  This "else" part tells what do if there weren't any. -->
        <p>Sorry, no posts matched your criteria.</p>
   
        <!-- REALLY stop The Loop. -->
        <?php endif; ?>
       ```
   
 * Any ideas of how to make this work?
 * Thanks,
 * Micah

The topic ‘Adding WordPress loop to a static .php file’ is closed to new replies.

## Tags

 * [last](https://wordpress.org/support/topic-tag/last/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [next](https://wordpress.org/support/topic-tag/next/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [websperations](https://wordpress.org/support/users/websperations/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/adding-wordpress-loop-to-a-static-php-file/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
