Title: Page.php Loop not working
Last modified: August 30, 2016

---

# Page.php Loop not working

 *  [jbarryweb](https://wordpress.org/support/users/jbarryweb/)
 * (@jbarryweb)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/pagephp-loop-not-working/)
 * At this point I’m stumped. I’ve set up many wordpress sites that use the loop
   on page.php, and they generally always work as expected returning the page information.
 * On a site I’m currently developing, on the page.php template, the loop is returning
   no posts. I’ve run get_queried_object(); and it returns all of the page information.
   Yet the loop still returns no posts. I’ve tried deactivating all plugins and 
   clearing out the functions.php file with no luck.
 * Category pages work as expected, using the default query and loop. If I rollback
   to the Twenty Fifteen theme, that also fixes the problem. I can also call “the_title()”
   outside of the loop and it returns the page title.
 * This is what the page.php file currently looks like:
 *     ```
       <?php
       /**
        * The template for displaying pages
        */
   
       get_header(); ?>
   
       	<div id="primary" class="content-area">
           <?php $queried_object = get_queried_object();
       	var_dump( $queried_object ); ?>
   
       		<main id="main" class="site-main" role="main">
   
       			<?php if (have_posts()) : while(have_posts()) : the_post(); ?>
                   	<?php the_title(); ?>
                   	<?php the_content(); ?>
   
                   <?php endwhile; else : ?>
                   	<h1>No posts were found.</h1>
                   <?php endif; ?>
   
       		</main><!-- .site-main -->
       	</div><!-- .content-area -->
   
       <?php get_footer(); ?>
       ```
   
 * This is what is output to the page:
 *     ```
       object(WP_Post)#367 (24) { ["ID"]=> int(6409) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2015-09-30 12:31:56" ["post_date_gmt"]=> string(19) "2015-09-30 16:31:56" ["post_content"]=> string(8) "asfdasdf" ["post_title"]=> string(4) "Test" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(4) "test" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2015-09-30 12:31:56" ["post_modified_gmt"]=> string(19) "2015-09-30 16:31:56" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(42) "http://centralpennparent.com/?page_id=6409" ["menu_order"]=> int(0) ["post_type"]=> string(4) "page" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" }
       No posts were found.
       ```
   
 * Can anyone else think of where the issue might be occurring?

Viewing 1 replies (of 1 total)

 *  [Dipak Gajjar](https://wordpress.org/support/users/dipakcg/)
 * (@dipakcg)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/pagephp-loop-not-working/#post-6604023)
 * **[@jbarryweb](https://wordpress.org/support/users/jbarryweb/)**, Have you tried
   to echo get_template_part()? I mean something like…
 *     ```
       <?php echo get_template_part(); ?>
   
       <?php the_content() ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Page.php Loop not working’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Dipak Gajjar](https://wordpress.org/support/users/dipakcg/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/pagephp-loop-not-working/#post-6604023)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
