Title: using posts outside wordpress
Last modified: August 19, 2016

---

# using posts outside wordpress

 *  [johnnyabracad](https://wordpress.org/support/users/johnnyabracad/)
 * (@johnnyabracad)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/using-posts-outside-wordpress/)
 * 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?

Viewing 1 replies (of 1 total)

 *  [j.org](https://wordpress.org/support/users/jorg-1/)
 * (@jorg-1)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/using-posts-outside-wordpress/#post-862532)
 * 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.

Viewing 1 replies (of 1 total)

The topic ‘using posts outside wordpress’ is closed to new replies.

## Tags

 * [external](https://wordpress.org/support/topic-tag/external/)
 * [formatting](https://wordpress.org/support/topic-tag/formatting/)
 * [html](https://wordpress.org/support/topic-tag/html/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [j.org](https://wordpress.org/support/users/jorg-1/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/using-posts-outside-wordpress/#post-862532)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
