WordPress.org

Support

Support » How-To and Troubleshooting » WYSIWYG no longer creates seperate Paragraphs… WTF?

WYSIWYG no longer creates seperate Paragraphs… WTF?

  • Ok, so I have seen many posts that sort of talk about the problem that I’m having, but it’s always worded strangely. Here’s the problem:

    In previous versions of WordPress, when using the WYSIWYG editor, pressing return creates a new paragraph. Now, when you press return, a space shows on the WYSIWYG editor, but when you look at your code on the blog, there is only one paragraph tag. I am very experienced with WordPress and CSS and php and all that stuff, so it’s not a styling thing. I have used many earlier versions of WordPress and never had this problem until recently. In earlier versions, if you are using the paragraph formatting, every time you press return, you are creating a new paragraph. This is no longer the case.

    I am looking for a real fix to this. Turning off the rich text editor is not a solution, but a workaround. I am trying to create a site for clients who may be editing content in the WYSIWYG editor, so I do not want it turned off. I tried removing one of the filters using:

    remove_filter(“the_content”, “wpautop”);

    in the functions.php file but with no luck. Is there a fix for this?

    Thanks!

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

    @esmi

    Forum Moderator

    Have you tried:

    – deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the Twenty Ten theme to rule out any theme-specific problems?

    resetting the plugins folder by FTP or phpMyAdmin? Sometimes, an apparently inactive plugin can still cause problems.

    Thanks Esmi,

    I will try this and report back

    Alright well I feel like an idiot!

    Changing to the 2010 theme has restored the individual paragraphs. I will start the debugging process. Any idea what can cause a bug like this?

    Thanks

    esmi

    @esmi

    Forum Moderator

    I’ve not come across this particular issue before but I’d be looking in functions.php or any file that adds a filter to the_content.

    Hmm, still checking but haven’t found anything yet…

    I know this is an old post and the 2010 theme doesn’t have this problem, but any chance this is similar to this problem:

    http://wordpress.org/support/topic/tiny-mce-strips-paragraph-tags?replies=7

    esmi

    @esmi

    Forum Moderator

    There’s no known bug in WP3.x of this type – unless you’re in the habit of switching between the HTML and Visual Editor tabs (which will wreck your markup).

    Ok, good to know. Thanks a lot for your help! If I figure this out, I’ll post it here. I think it’s either a problem my theme’s index.php file or a jQuery complication. Thanks again!

    Alright, well I’ve figured out the problem and feel pretty stupid 😀

    Turns out I was focusing on one section of the content. Particularly, a section where I was drawing the content using this method:

    <?php
    $contact_id = 73;
    $contact_post_id = get_post($contact_id);
    $title = $contact_post_id->post_title;
    $content = $contact_post_id->post_content;
    ?>
    
    <li id="contact_div" class="invis post">
    <div id="contact_content">
    <h4><?php echo $title; ?></h4>
    <?php echo $content; ?>
    </div>
    </li>

    Sorry to bother you guys with a problem that stemmed from my lack of troubleshooting! Not sure what the protocol in this situation is, but should I just delete this post, since the problem is actually much different than the title suggests?

    thanks

    esmi

    @esmi

    Forum Moderator

    No – the posts might still help someone else with the same or a very similar problem.

    No – the posts might still help someone else with the same or a very similar problem.

    Yes, that someone is me. Thanks for leaving the post, posted.

    @owstopit, can you please explain, for a newbie like myself, your solution?

    I was drawing the content using this method:

    <?php
    $contact_id = 73;
    $contact_post_id = get_post($contact_id);
    $title = $contact_post_id->post_title;
    $content = $contact_post_id->post_content;
    ?>
    
    <li id="contact_div" class="invis post">
    <div id="contact_content">
    <h4><?php echo $title; ?></h4>
    <?php echo $content; ?>
    </div>
    </li>

    what?….

    Hey kdbates!

    Haha, sorry let me explain what’s goin on here!

    The method I was using I learned from this page:

    http://codex.wordpress.org/Function_Reference/get_post

    This is just one method to get a specific post’s content. I set the post’s id to a variable using $contact_id = 73 (73 being the id of the contact page) and then pass the id to the get_post() function. You can’t pass the value 73 by itself, it must be within a variable which is why I set it to the $contact_id variable. Next I put the results of the get_post() into a variable called $contact_post_id. Finally I access the property “post_title” and “post_id” from the post object that is returned to the $contact_post_id variable. Now I’ve got a variable called $title containing the post’s title and $content containing the content.

    Not sure if that’s what you wanted to know, but thought I’d include it just in case. Now the important part:

    When you use the_content() function to show a post or page’s content, the content receives formatting, aka the paragraph tags and such that I was hoping for. Since I didn’t end up using the_content() function, I was losing this formatting. Once I realized this, I opted for a different method of getting the content for the post. The method I used instead was the query_posts() function. Here’s all of the nitty gritty about this function:

    http://codex.wordpress.org/Function_Reference/query_posts

    On a specific wordpress page (such as an “about” page, for example) there is this piece of code:

    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

    and further down in the page.php code you’ll see

    <?php the_content(); ?>

    This will take the content from whatever page you’re surfing. So if you’re on the About page, the content will be pulled from whatever is typed in the WYSIWYG editor on the about page editor. Using query_posts(), you’re telling wordpress to look at a different page than the one your surfing. I ended up using this code:

    <?php
    
    	//The Query
    	query_posts('page_id=73&posts_per_page=-1');
    
    	//The Loop
    	if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    	<li id="contact_div" class="invis post section">
    	        <div id="contact_content" class="section_content">
    		        <h4><?php the_title(); ?></h4>
    		        <?php the_content(); ?>
    	        </div>
    	</li>
    
    	<?php endwhile; ?>
    
    	<?php endif; ?>
    
            <?php wp_reset_query(); ?>

    So now, because of the query_posts() function, when I call “the_content();” I am actually pulling the content from the page with the id of 73 instead of the page I’m currently on. So I am able to pull in content from another page and because I am using the_content(); function, the formatting (each line wrapped in paragraph tags) remains and looks the way I typed it in in the WYSIWYG editor.

    Ok I hope this explanation wasn’t totally over-detailed but I thought I’d try to be extra thorough 😀

    Hope this helps 😛

    Hi owstopit,

    Thank you so much for the great explanation – I really appreciate it.
    Have a great holiday.

    kdbates

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘WYSIWYG no longer creates seperate Paragraphs… WTF?’ is closed to new replies.
Skip to toolbar