I'm trying to display posts outside of the wordpress system (another system is pulling from the mysql database). However, the posts stored in the database seem to be void of <p> tags and different from what was entered in text mode (or visual mode).

For example, entering this in the editor


<p>Sentence here with more content</p>

results in this saved to the database:

Sentence here with more content
  • Perhaps the external system could use a RSS feed generated by your WP site? Commented Oct 12, 2015 at 21:43
  • See this question.
    – Milo
    Commented Oct 12, 2015 at 21:44

1 Answer 1


The best ways to get content OUTSIDE of WordPress would be (listed in my order of preference):

  1. By using the WP REST API plugin (soon to be fully integrated into core)
  2. Via RSS feed as mentioned by @AricWatson in the comments above.
  3. Direct queries into the MySQL wp_posts and wp_postmeta tables.

When content is rendered INSIDE of WordPress there are a number of "filters" applied to the content before it is output on the screen. Things like paragraph tags, shortcodes and other formatting and tag adjustments are all applied AFTER the content is pulled from the database BEFORE it's rendered in the browser.

If you absolutely must query the DB directly for the content in question your best bet for an accurate render will be to apply some of your own custom filters to the content. Some examples might include:

  • converting newline characters to paragraphs
  • stripping out shortcode references
  • applying your own custom shortcode filters on the content
  • replacing WP specific class names with classes of your own (if you needed to)

The primary reason to avoid direct MYSQL queries to retrieve WP content is that WP is already well equipped to query, parse and render the content in a variety of formats. Using WP to feed other applications is a common practice and can be quite painless when done right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.