WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] HTML Comment in Post Content Makes Everything Commented Out (8 posts)

  1. dkotter
    Member
    Posted 1 year ago #

    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.

  2. dkotter
    Member
    Posted 1 year ago #

    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.

  3. MarcusPope
    Member
    Posted 1 year ago #

    @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 - http://wordpress.org/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.

  4. MarcusPope
    Member
    Posted 1 year ago #

    Forgot to click notify me of follow-up posts, otherwise I'll never find this thread again :D

  5. rdela
    Member
    Posted 1 year ago #

    @MarcusPope hell yes!
    plugin works like a charm
    http://wordpress.org/extend/plugins/preserved-html-editor-markup/

  6. MarcusPope
    Member
    Posted 1 year ago #

    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 :D I'll be posting updates on my support site http://www.marcuspope.com/wordpress if you want to be updated on that.

    Thanks!
    -Marcus

  7. tsilenzio
    Member
    Posted 1 year ago #

    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> <!-- -->
  8. Toby
    Member
    Posted 10 months ago #

    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??

Topic Closed

This topic has been closed to new replies.

About this Topic