Monday, June 3, 2013

How to display articles from a wordpress site to a non-wordpress site?

The following solution will work only if the two sites are hosted on the same server.

- Include the wp-config.php to your non-wordpress site.
- To display news you may use the following:

$post = get_post($articleID); // to get a specific article
$args = array(
            'post_type' => 'post',
            'numberposts' => 50,
            'post_status' => 'publish',
            'category' => $articleCategory // will accept comma separated categories
            );
Note: If you're non-wordpress site uses PHP's $_SESSION for log in or other things, be sure to modify the wp-includes/load.php

Change the line:
$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
To:
$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES );

No comments:

Post a Comment