• Dr. Frankenbox

    (@dr-frankenbox)


    I am developing a custom theme for one of the websites I run, and for some reason when my theme is enabled, line breaks in the “Visual” editor aren’t translated to <p> or <br> tags in the post/page code. I didn’t disable wpautop, nor did I customize anything in the admin interface. What could cause this behavior?

Viewing 5 replies - 1 through 5 (of 5 total)
  • mheltone

    (@mheltone)

    Can you post your page.php here…
    I could try to help you if you do.

    Thread Starter Dr. Frankenbox

    (@dr-frankenbox)

    Certainly. It’s very simplistic. The only unusual thing about it is that for a given page – the main page – it embeds The Loop for posts as well, to display news posts on that page, underneath the regular page content. The problem I’m reporting hasn’t been observed on the main page, so that code should be irrelevant.

    <?php
    	$page = get_page($_GET['page_id']);
    	if (!isset($page))
    	{
    		include('404.php');
    	}
    	else
    	{
    		echo "<h1>";
    		echo $page->post_title;
    		echo "</h1>";
    		echo $page->post_content;
    	}
    	if ($page->post_title == "Main")
    	{
    		query_posts('category_name=news&posts_per_page=4');
    		if (!have_posts()) { /* No posts to display */ ?>
    		<h2>No Posts Found</h2>
    		<p>
    			No news posts were found matching the specified criteria.
    		</p>
    	<?php	}  else { ?>
    		<div id="newsposts">
    	<?php		while (have_posts())
    			{
    				the_post();
    	?>
    		<h2><?php the_date(); ?></h2>
    		<h3><?php the_title(); ?></h3>
    		<?php the_content(); ?>
    	<?php		}
    		} ?>
    		</div>
    <?php
    	}
    ?>
    mheltone

    (@mheltone)

    It’s probably because your contents are inside the <div id=”newsposts”>
    Do you any styles on that ID?

    Try putting your <?php the_content(); ?>

    inside this div.

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php the_content(); ?>
    </div>

    Try that.. Hope that fix it.

    Thread Starter Dr. Frankenbox

    (@dr-frankenbox)

    I doubt that will make a difference. I’m sorry I wasn’t too clear about it at first, but the problem I’m seeing happens with the page content, which isn’t in any div shown here (though this whole page gets wrapped in a div with id=”content”). I don’t have any styles on #newsposts (yet), but I don’t have any styles defined for #post-X either. Besides all that, the problem is that the <p> tags simply aren’t there, not that they are there but without the proper spacing defined for them. I don’t think a stylesheet could fix that.

    Thread Starter Dr. Frankenbox

    (@dr-frankenbox)

    No suggestions? I can’t imagine what I’m doing wrong. I double-checked, and the filter is registered in default-filters.php:

    add_filter( $filter, 'wpautop' );

    but it isn’t doing its job. Even if I call it directly, the <p> tags simply aren’t there:

    $post = get_the_content();
    // Add <p> tags since WP isn't doing it for us
    $post = wpautop($post);
    echo $post;
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Why does my theme kill line breaks?’ is closed to new replies.