• Resolved Darin Kotter

    (@dkotter)


    So I imported quite a few posts from movable type into WordPress. I found out after the fact that some of these posts have an image at the top of the post content that is commented out: <!--<img src="something" />-->

    This would be fine, but for whatever reason, WordPress interprets that comment has enclosing all the content, not just the image. So when you view the post on the front-end, nothing shows up.

    So I don’t know why this is happening or if there’s some easy way to get WordPress to not apply the comment to places it shouldn’t be.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Darin Kotter

    (@dkotter)

    Okay found out what was causing the issue. It was the wptexturize function, it was turning — into an en-dash. So for those having similar issues, you can remove that function from the content and excerpt like so:

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

    Just be aware that you then lose that formatting. In my case I’d rather lose that formatting then not have my posts show at all.

    @dkotter – so I found this page on google while trying to find a fix that didn’t involve disabling the entire wptexturize filter. And for some reason wordpress forums don’t offer a link back to the support page your issue is referencing so I have no idea what this was in context to. However I will say that my plugin – https://www.ads-software.com/extend/plugins/preserved-html-editor-markup/ does solve the problem while still enabling the good parts of wptexturize. I’m publishing version 1.2 today so keep an eye out for that if you are interested in getting the benefit of wptexturize without the html comment malforming.

    Forgot to click notify me of follow-up posts, otherwise I’ll never find this thread again ??

    Awesome, glad to hear that it works for you. Once my life settles back down after the birth of my daughter in a couple weeks I plan on adding some more improvements to the html editor that make it more like an IDE and less like notepad.exe ?? I’ll be posting updates on my support site https://www.marcuspope.com/wordpress if you want to be updated on that.

    Thanks!
    -Marcus

    The following works

    <!-- content here -->

    This however does not because –> is converted to &#8211&#8211> or something similar

    <!-- <some_html_tag></some_html_tag> -->

    Due to the fact that html tags cannot be inside a comment for it to display properly the following will work in all browsers

    <!-- <html_tag><more_html_tags>...</more_html_tags></html_tag> <!-- -->

    None of the above solutions are working for me.

    If I comment something like this

    <!--<p>[ENTER DESCRIPTION]</p>-->

    After hitting the publish button I get

    <!--</p>
    <p>[ENTER DESCRIPTION]</p>
    <p>--></p>

    I have removed all filters I can think of in my functions.php

    remove_filter( 'the_content', 'wptexturize' );
    remove_filter('the_content', 'convert_char' );
    remove_filter('the_content', 'wpautop' );

    I have tried plugins also but still cannot use html comment tags.

    Anyone found a solution for this??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘HTML Comment in Post Content Makes Everything Commented Out’ is closed to new replies.