Forums

Preserve HTML with get_pages (3 posts)

  1. Dobby89
    Member
    Posted 1 year ago #

    I'm currently using the get_pages() function to return child pages of a parent page. I'm getting the content out of the returned array fine, but what I'd like to know is, is it possible to get the content while still preserving the HTML of each "post_content" array element.

    As I say, the code structure I'm using is working fine and returns the content MINUS THE HTML.

    $array = get_pages($arguments);
    foreach ($array as $page)
    {
    $content = $page->post_content;
    }

    ..How can I make it so $content contains "<p>content</p>", for example as opposed to "content", which it currently returns?

  2. Dobby89
    Member
    Posted 1 year ago #

    http://wordpress.org/extend/plugins/fckeditor-for-wordpress-plugin/

    I found this plugin, which replaces the default text editor with one that doesn't seem to strip HTML from the post/page content before it is delieverd by the get_pages() function.

    Unfortunately it doesn't have an excerpt field and probably lacks a few other things along with it.

  3. hello-there
    Member
    Posted 10 months ago #

    Solution is «apply_filters»

    $page_id = '80';
    $page_data = get_page( $page_id );
    $content = apply_filters('the_content', $page_data->post_content);

Topic Closed

This topic has been closed to new replies.

About this Topic