Support » Plugins » Database content to formatted content

  • Resolved crutkas


    I’m currently attempting to export my data and I have the post_content but was wondering what function I would have to run that data though to get the new lines into BR tags and ignore div tags new lines. My end goal is to make it render exactly like how the current page does.

    I was thinking maybe it was wpautop() in formatting.php but that is only referenced in wp_richedit_pre which looks like it deals with only the rich text editor, not end result. Then I was thinking maybe something with the add_filter function but there are tons of options for that.

    Could anyone please inform me what function I need to pass the post_content through to get it to format properly?

    Much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kafkaesqui


    You’re on the right path.

    To perform all formatting on your post content (including any done by plugins and such), you typically want to pass it through ‘the_content’ API by using apply_filters(), like:

    $your_text_var = apply_filters('the_content', $your_text_var);



    I tried but it didn’t appear to work. I got the same data out that I sent in.

    <content type="text"><![CDATA[<?php echo apply_filters('the_content', $post->post_content) ?>]]></content>

    I would like the content for (this is in the DB)

    foobar too

    to become (think I got the wordpress translation correct)

    <p>foobar too</p>



    got it working with the wpautop function. Thanks!

    I am trying something very similar.
    I have the post_content I want to display in $postText.

    I have a function like

    require 'wp-includes/classes.php';
    require 'wp-includes/functions.php';
    require 'wp-includes/plugin.php' ;
    require 'wp-includes/formatting.php';
    function aeClean($postText) {
    	$postText = apply_filters('the_content', $postText);
    	$postText = wpautop($postText);

    I get this error message:
    Fatal error: Call to undefined function get_shortcode_regex() in /pathToMySite/wp-includes/formatting.php on line 100

    when I call the $postText = wpautop($postText); line.
    Without the call to wpautop() the content is returned, but does not seem to be altered.

    And I do not see anything relevant at line 100 or get_shortcode_regex() in formatting.php

    My goal is to get ready for browser text directly from the post_content field. Any help would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Database content to formatted content’ is closed to new replies.