0

I have a page.php file wich simply looks like this:

<?php get_header(); ?>
<div class="clear"></div>

<div class="clear"></div>
<?php get_footer(); ?>

On the other hand I have made two pages named About and Contact Us in my WordPress admin panel and I've added them to my site's top menu.

Now when I add some content to one of these two pages and open it by clicking its name from the top menu the content is not shown. How can I fix this issue?

I want to show all of my self-made pages (pages that are made using WordPress admin panel and are different from single.pho, index.php, category.php and search.php) using the page.php layout. How can I do this?

2

You need to include a loop to retrieve the page content. Something like:

<div id="primary" class="site-content">
    <div id="content" role="main">

     //BELOW HERE
      <?php while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', 'page' ); ?>

        <?php comments_template( '', true ); ?>

      <?php endwhile; // end of the loop. ?>

     //ABOVE HERE

      </div><!-- #content -->
</div><!-- #primary -->

More on Page Templates:

Possible Tutorial Starting Point

And Page Templates from the WP Codex on Page templates:

page.php — If a specialized template that includes the page’s ID is not found, WordPress looks for and uses the theme’s default page template.

So if you haven't assigned anything in the admin, and no more specialized templates exist, your page.php file is being called.

  • @naser.Sadeghi no problem! – hwl May 12 '17 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.