WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP Bug recognizing page.php templates/loading content? (4 posts)

  1. ljkerley
    Member
    Posted 4 years ago #

    I have a problem with page.php templates and loading page content.
    - I wanted an About page so I created a page.php template, using the default theme and the documentation as a guide. I created the About page in the 'pages' section of the WP admin console.
    - I would have expected that I needed to assign the page.php template to the About page. Strangely, the page.php template I created does not show up in the template drop down in the Quick Edit page. I don't know why and this worried me.
    - Despite this, when I use the preview function in the pages admin area, the page generates fine using the page.php template, and looks just the way it should. I thought the WP somehow was smart enough to 'find' the page.php template anyway.
    - I published the about page last night. When I checked the website real-time, again the page generated just fine.
    - Then this morning I checked my website and the About page content was no longer appearing on the page. However, parts of the page.php generated OK. The sidebars and the footer showed up. But the content was not. Now, if the page.php template didn't appear at all, I would assume the problem had to be the template assignment. But it seems like WP is still finding the page.php template because it is partially generated.
    - I recreated the page.php to see if that would provoke page.php to show up in the templates drop down. It didn't.
    - I deleted and then recreated the About page content to provoke some kind of reaction. There was none.
    - So I added HTML to the template file to test where the problem happens. WP is definitely finding the template because the HTML I inserted at the top of the file appears. It seemed like there is maybe a problem in the loop...? Maybe I am missing some statements? I provided the code from my loop. Can someone tell me what is wrong? (Note: I omitted comments on purpose.)
    - It still may be that the assignment is the root of the problem, but if the page.php does not show up in the drop down, what can I do? It seems like it is a UI bug in the admin console or something.
    Thanks for the help.

    <div id="main">
    <div id="content2">
    <p> Testing to see if this template is being called. Yes, this text appears.</p>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom:0px;">
    <tr>
    <td>
    <h1 class="posttitle">
    <?php the_title(); ?></h1>
    </td>
    </tr>
    </table>

    <?php the_content(__('(more...)')); ?>

    <?php endwhile; else: ?>
    <?php endif; ?>
    </div>
    </div>

  2. ClaytonJames
    Member
    Posted 4 years ago #

    I think this might contain some of the information that you are after.

    http://wordpress.org/support/topic/319522?replies=8#post-1241402

  3. Arnold Goodway
    Member
    Posted 4 years ago #

    The standard page.php will not appear in the template drop down. WordPress will read your page.php if it exists. If there is no such file and the default theme is loaded WordPress will use the page.php from that theme. If you want to make special changes to your about page you will have to create a page template but you will have to name it anything but page.php. If you for example, name it about.php you will find it in the template dropdown.

    Your code looks okay to me, I just cannot see why you are placing the title in a table and the content outside the table.

  4. ljkerley
    Member
    Posted 4 years ago #

    The thing I 'love' about programming is that sometimes the cause of a problem is not readily apparent based on the symptoms...
    The problem seemed to come not from my page template but from my horizontal navigation menu. I had used the About page permalink as the source location in the anchor tag. When I deleted the About page and recreated it, the permalink changed (of course). Once I updated the permalink reference, the About content loaded fine.

    Thanks for the help, though.

    (Arnold, the table tag thing you saw was 'legacy' code from an earlier layout attempt - I was putting graphics in the title and used the table to control the placement. I dropped the idea but forgot to remove the code.)

Topic Closed

This topic has been closed to new replies.

About this Topic