0

I'm raising this problem because I don't find a latest answer and the problem still exist to me.

I'm running wordpress 4.2.2 with x theme when I'm editing the content via WP default editor (tinymce). I'm having lot of problem with HTML format. For example if I edit the content in VISUAL/TEXT mode in the front-end I'm getting empty <p></p> tags even sometime I noticed if I add content like this:

<ul>
   <li><a href="#">Content1</a></li>
   <li><a href="#">Content2</a></li>
   <li><a href="#">Content3</a></li>
</ul>

it'll be transform into: (this is happening once in while)

<ul>
       <li><a href="#"></a>Content1</li>
       <li><a href="#"></a>Content2</li>
       <li><a href="#"></a>Content3</li>
    </ul>

My questions are:

  • Is there a solution for this?
  • Or can we change the default editor to the plain text area? perhaps disable the tinymce editor
2
  • When you receive empty P tags, what exactly is done in the TinyMCE editor? Is there for example an extra empty line in between the paragraphs? Can you please try to recreate the exact steps that you take? As for empty lines wrapped in P tags, I hook into save_post and remove them, I can post this solution if your question is directly related to this issue.
    – Christine Cooper
    May 31, 2015 at 19:47
  • In addition to the below answer by @mtinsley , If you want to disable TinyMCE editor complete then you can do that from "Users > Your Profile" check 'Disable Visual Editor'. Jun 1, 2015 at 5:21

3 Answers 3

5
+50

You can disable the visual editor entirely in your profile settings. If you need to disable it on a per page basis, take a look at this answer.

Using text mode may not solve the empty paragraph problem, the wpautop filter is applied to the content regardless of how the content is edited. You can remove the filter, but then you'll have to manually break and paragraph your content.

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

Alternatively, you can use a filter to strip out any empty paragraphs when displaying your content:

https://gist.github.com/ninnypants/1668216

Regarding the issue with the anchors, I haven't had this particular issue with the editor. In general, if I am writing a lot of HTML in a post I like to use a "raw html" plugin. For example: https://wordpress.org/plugins/preserved-html-editor-markup-plus/

1

It's called wpautop. There is a plugin that will help you to effectively deal with this

Please check PS Disable Auto Formatting

Hope it helps

0

you can use this if you looking any certain post type

remove_filter('the_content','wpautop');

//decide when you want to apply the auto paragraph

add_filter('the_content','my_custom_formatting');

function my_custom_formatting($content){
if(get_post_type()=='my_custom_post') //if it does not work, you may want to pass the current post object to get_post_type
    return $content;//no autop
else
 return wpautop($content);
}

please find here remove_filter( 'the_content', 'wpautop' ); only for certain post types

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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