Fetch custom posts from another WP site?


I have two WordPress installations on two different servers. On the external site, I have a custom post type (FAQ) that stores all my FAQ posts. I want to load this custom post type into the internal site, so I do not have to double-post the content. I have used <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php'); ?> in the past, but this time the two servers do not share the same $_SERVER.


Instead of using $_SERVER['DOCUMENT_ROOT'], you can use the file path to the WordPress installation on the external site. Then, you can include the wp-load.php file from that installation. Here is an example code:

// Set the file path to the external WordPress installation
$external_wp_path = '/path/to/external/wordpress';

// Load the wp-load.php file from the external WordPress installation
require_once($external_wp_path . '/wp-load.php');

// Now you can access the FAQ custom post type from the external site