WordPress.org

Ready to get started?Download WordPress

Forums

using posts outside wordpress (2 posts)

  1. johnnyabracad
    Member
    Posted 5 years ago #

    I have been trying to use wordpress content in non-wordpress pages. PHP retrieves the posts with the query:
    SELECT post_title, post_content FROM wp_posts WHERE ID=$postno

    On closer inspection it appears most of the content in the database does not include <p> tags, relying on linebreak and return chaacters to delimit paragraphs. But some of the posts do include <p> tags.

    I recently upgraded to WP2.6, does the above suggest the database was corrupted in the upgrade?

    However, within wordpress all pages display correctly and include <p> tags. Is there some PHP function that adds the necessary formatting to the content retrieved from the database?

  2. j.org
    Member
    Posted 5 years ago #

    Hi johnnyabracad,

    I just run into a similar problem and there definitely is some built-in stuff to magically convert linebreaks to paragraphs. However, it's in general not advisable to use such a function directly (don't know it btw) instead try to get post instances as they are delivered via the wordpress function get_posts($args) and afterwards use setup_postdata($post) to prepare the use of the_content(). The latter directly prints the desired content, including those missing paragraphs.

    I can imagine that this won't get too easy from outside of wordpress, but this is the way I deal with it within my themes.

    Of course you can just try to mimic the same functionality by replacing linebreaks with paragraphs, but I doubt it will be easier.

    Hope this help a little,

    ~~~Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic