• Hi there,

    Since September of last year (2017) my start page hasn’t been rendering properly. It happened after an update.

    I use my own theme (based on a standard theme) and what I have established so far is that the code in “page.php” is rendered until the following line of code is reached:

    <?php the_content(‘<p class=”serif”>Read the rest of this page »</p>’); ?>

    Then there’s nothing. If I take out this line, the page is rendered, but the content of the page is missing. If I go to edit the page (in my dashboard), the content is still there, it just isn’t displayed. All other pages suffer from the same problem.

    All posts render correctly however – you just can’t get to them from the front page!

    Finally, I have tried to change the site theme, but when previewing have the same problem. I’ve even replace the file post.template.php (where the function “the_content” is defined) with a new version, just in case it was corrupt, also with no joy.

    What else should I try?

    Thanks.

    Goz

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    what happens if you change that to be just “the_content()”?

    Thread Starter gozzle

    (@gozzle)

    Hi Steve,

    Exactly the same, unfortunately.

    Any other ideas?

    Thanks.

    Goz

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Please show your entire template (.php file) on wpbin.io or gist.github.com and put a link here.

    Thread Starter gozzle

    (@gozzle)

    Hi Steve, the page.php file is so small, I can paste it here:

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Or do you mean another .php file?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Errors like this are logged. Check the error log on your server. If you can’t find the log, please contact your host.
    Enable wp_debug and wp_debug_log and after an error, look at wp-content/debug.log to see if anything gets logged there. https://codex.wordpress.org/Debugging_in_WordPress

    Thread Starter gozzle

    (@gozzle)

    So it’s a server side problem and not a WP problem?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Ignore that last response… I think I was replying to something else.

    I don’t see anything in your code that looks wrong to me. If the_title() works, then the_content() should.

    Thread Starter gozzle

    (@gozzle)

    After the header, all that’s rendering on the actual page is:

    <div id=”content” class=”narrowcolumn”>

    <div class=”post” id=”post-29″>
    <h2>1) How it all started…..</h2>
    <div class=”entry”>

    nothing more….

    Where should I start investigating?

    Any help gratefully received.

    Best regards,

    Martin

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    try doing a print_r() of the post object just to see what you’ve got.

    Thread Starter gozzle

    (@gozzle)

    Thanks Steve. How do I reference the post object?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    More or less — warning: syntax errors are likely.

    <?php 
       global $post;
       get_header(); 
    ?>
      <div id="content" class="narrowcolumn">
      <?php 
       if (have_posts()) {
           while (have_posts()) {
            the_post(); 
            echo '<pre>'; print_r($post); echo '</pre>';
       ?>
    	<div class="post" id="post-<?php the_ID(); ?>">
    	<h2><?php the_title(); ?></h2>
      	<div class="entry">
    	<?php 
              the_content('<p class="serif">Read the rest of this page &raquo;</p>'); 
            ?>
    	<?php 
               wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); 
             ?>
    	</div>
    	</div>
    	<?php 
                } // while
               } // if
             ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    	</div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter gozzle

    (@gozzle)

    Ok, let me try. I’ll report back.

    Thanks again Steve

    Martin

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

The topic ‘rendering pages & the_content’ is closed to new replies.