WordPress.org

Ready to get started?Download WordPress

Forums

How to treat post_content_filtered field (2 posts)

  1. kanonji
    Member
    Posted 1 year ago #

    I'm writing a plugin that allow me to write posts with something like markdown.
    Two sort of data( Original markdown text and converted html ) are needed to stored in database.

    `
    markdown is in post_content_filtered.
    converted html is in post_content.
    `

    or

    `
    markdown is in post_content.
    converted html is in post_content_filtered.
    `

    I wonder which is better for that post_content_filtered designed to be used.

    I'm looking for some plugins using post_content_filtered. I will refer how to treat post_content_filtered. Of course, any other adovice is helpful.

    -------

    ## markdown is in post_content_filtered.

    My code stores markdown text written in default textarea editor to post_content_filtered.
    But there are lots of point to hook I need to code.
    For example, post_content_filtered will lost on scheduled post, bulk editing, rivision switching on default behavior of WordPress.
    The markdown text is origianl. But WordPress exporter dosen't export post_content_filtered.

    ## converted html is in post_content_filtered.

    Since html is converted, post_content_filtered seems like right field to store the html.
    So I'm considering to store the markdown to post_content.
    But WordPress and most plugins expect html in the post_content.
    I need to replace markdown with converted html just after retrieving posts data from database.
    I don't know how to do it on every retrieving.
    For example, searching post is only from the post_content, and I can't find any hook.

  2. bcworkz
    Member
    Posted 1 year ago #

    As you've identified, you're sort of fighting WP with either approach. Just an alternate thought, use it or not, or maybe it'll lead you to an even better thought. How about storing your markdown in postmeta, and feeding the converted HTML to post_content as is commonly expected? Let WP do what it does with the other fields, don't fight it.

    There's quite possibly some fatal flaw I don't know about. No matter, I'm really just suggesting you break away from your current either/or dilemma and consider a completely different approach.

Topic Closed

This topic has been closed to new replies.

About this Topic