Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Plugins
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Docs
  • Support
    • Frequently Asked Questions
    • Feature Request
    • Support Ticket
  • account_circle
PRO Plugin
Howdy! How can we help you?
  • Introduction

    • Quick Start
    • Frequently Asked Questions
    • Will this work with my API?
    • Understanding API docs
    • Step by Step Example
  • Setup

    • Setup Page
    • Endpoint Page
    • Parameters - Query String
    • Parameters - Headers
    • Parameters - Body POST
    • Shortcode
    • Template Tag
    • Gutenberg Block
  • Connecting your API

    • API Key in Headers
    • API Key in Query String
    • Authentication & Authorization
  • Output API Data

    • Format API to HTML
    • Format API to HTML Table
    • Format API to Image Gallery
    • Format JSON Data
  • Integrations

    • Send form data to API
    • WPForms to API
    • Gravity Forms to API
    • Contact Form 7 to API
    • WooCommerce to API
    • WooCommerce API Product Sync
    • wpDataTables to API
    • Connect WordPress to OpenAI
    • Connect RapidAPI to WordPress
    • Connect Zoho CRM to WordPress
    • Page Builders (Elementor, DIVI)
    • Formidable Forms to API
    • Elementor Form to API
    • JetFormBuilder to API
    • Fluent Forms to API
    • WS Form to API
    • Ninja Tables to API
    • Easy Digital Downloads(EDD) API Product Sync
    • Ultimate Member Forms to API
    • Ninja Forms to API
    • WordPress API Posts Sync
  • Tips & Tricks

    • Filters & Action Hooks
    • Code Snippets Plugin
    • Troubleshooting
    • Code Snippets
  • PRO Plugin

    • Installation
    • Actions
    • Tokens
    • Caching
    • Nested data
    • Chaining API calls
    • Dynamic Variables
    • Format API to HTML
    • Call API on user registration
    • Using AJAX to trigger API call
    • Base64 Encoding
    • Licensing
    • Filters & Action Hooks
  • OAuth 2.0 Plugin

    • Installation
    • How it works
    • Grant Type - Client Credentials
    • Grant Type - Authorization Code
    • Licensing
  • API to Posts Plugin

    • Installation
    • Getting Started
    • Multiple Endpoints
    • Mapping Fields
    • Filters & Action Hooks
    • Pagination
Features in this article are available in the API to Posts plugin.

In this tutorial, we’ll walk you through the process of importing posts from one WordPress site to another.

Requirements

  • Code Snippets Plugin
  • Free WPGetAPI plugin
  • API to Posts plugin
  • A WordPress site to get the posts

Step 1: Setup API & endpoint

Start by setting up the API to retrieve posts from the another WordPress site.

This is the WordPress site API settings required:

In this example:

  • The another wordpress site is: https://ilj.local
  • The endpoint used is: /wp-json/wp/v2/posts — this is the standard endpoint for retrieving posts via the WordPress REST API.

For detailed reference, check the WordPress REST API documentation.

Step 2: Add Custom Code for Pagination (Optional)

By default, the WordPress REST API returns 10 posts per request. To fetch all posts with pagination, you can use the following custom snippet. Add it to your theme’s functions.php file, or utilize the Code Snippets Plugin.


/**
 * Modify the raw API data returned by WPGetAPI.
 *
 * Adds pagination support by extracting `x-wp-totalpages` or `X-WP-TotalPages` from the headers
 * and parsing `page` from query variables if available.
 *
 * @param mixed $data      The raw API response data.
 * @param object $wpgetapi The WPGetAPI object instance.
 *
 * @return mixed Modified response data or original data.
 */
function wpgetapi_modify_output( $data, $wpgetapi ) {
	if ( empty( $data ) ) {
		return __( 'Sorry, no data returned.', 'text-domain' );
	}

	if ( 'ilj_local' == $wpgetapi->api_id ) {
		$response        = array();
		$response_header = $wpgetapi->response_header;
		$query_param     = $wpgetapi->args;

		$response['posts'] = $data;

		$total_pages_header = isset( $response_header['x-wp-totalpages'] )
			? $response_header['x-wp-totalpages']
			: ( $response_header['X-WP-TotalPages'] ?? null );

                if ( ! empty( $total_pages_header ) ) {
			$response['total_pages'] = absint( $total_pages_header );
			$response['page']        = 1;

			if ( ! empty( $query_param['query_variables'] ) ) {
				$vars        = explode( ',', $query_param['query_variables'] );
				$final_array = array();

				foreach ( $vars as $var ) {
					$couple = explode( '=', $var );
					if ( count( $couple ) === 2 ) {
						$final_array[ trim( $couple[0] ) ] = trim( $couple[1] );
					}
				}

				$response['page'] = isset( $final_array['page'] ) ? absint( $final_array['page'] ) : 1;
			}

			return $response;
		}	
	}

	return $data;
}
add_filter( 'wpgetapi_raw_data', 'wpgetapi_modify_output', 10, 2 );

Replace ilj_local with the actual API ID you’ve configured in WPGetAPI.

Step 3: Create Posts from the another WordPress site

Once your API is set up and optional pagination is handled, follow these steps to import the posts.

  • configure how the API data will be imported
  • select ‘Post’ as the post type
  • run the ‘API Importer’
  • map the API data to the Post fields
  • run the ‘Post Creator’

That’s it!
You’ve successfully imported posts from another WordPress site. You can map data to standard post fields such as title, content, excerpt, date, categories, featured images, custom fields and more.


Going further

Check out the full tutorial with a step-by-step guide here. This article runs through the exact process of creating posts from posts from one WordPress site to another WordPress site.

On this page
contact_support

Still not sure?

APIs can be daunting and sometimes downright confusing.

But we are here to help! Our support is amazing and we can assist you with any setup required and ensure your API integrations are a success!

Ask Us Anything

Connect your WordPress website to external APIs without writing a single line of code. Send data from WordPress to your API or display data from your API within WordPress.

Support

  • Documentation
  • Support Ticket
  • Refund Policy
  • Contact Us
  • About Us
  • Affiliates

Articles

  • Quick Start Guide
  • WooCommerce Orders to API
  • WooCommerce API Products Sync
  • Contact Form 7 to API
  • WPForms to API
  • Gravity Forms to API
  • WordPress to RapidAPI

WordPress API Plugins

  • Free WPGetAPI Plugin
  • PRO Plugin
  • API to Posts Plugin Plugin
  • OAuth 2.0 Authorization Plugin

© 2025 WPGetAPI. All Rights Reserved.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.