Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
  • 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
  • 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

API to Posts Plugin – Filter & Action Hooks

These actions and filters help extend or modify the functionality of the API to Posts plugin. Code snippets would need to be added to your themes functions.php file.


Filter: wpgetapi_api_to_posts_mapped_value

This filter allows you to modify any value when importing. Handy for date formatting or translations.

function wpgetapi_modify_a_value( $value ) {
    if( $value === 'sold out' ) {
        $value = 'Ausverkauft';
    } 

    // looks for date format like 23.09.2023 and changes to 2023-09-23
    if( preg_match('/^(\d{2}).(\d{2}).(\d{4})$/', $date) ) {
        $DateTime = DateTime::createFromFormat( 'd.m.Y', $value );
        $value = $DateTime->format( 'Y-m-d' );
    } 
    
    return $value;
}
add_filter( 'wpgetapi_api_to_posts_mapped_value', 'wpgetapi_modify_a_value', 10, 1 );

Filter: wpgetapi_api_to_posts_pagination_delay

This filter is only relevant for endpoints that utilise paging. This filter allows you to set a delay between calling each paginated endpoint. The default is set to 0.2 and we have this delay in place to avoid ‘too many requests’ errors.

function wpgetapi_modify_pagination_delay( $value ) {
    return 0.4;
}
add_filter( 'wpgetapi_api_to_posts_pagination_delay', 'wpgetapi_modify_pagination_delay', 10, 1 );

Filter: wpgetapi_api_to_posts_importer_items_before_save

This filter allows you to modify your API data before it is saved when running the importer. In the example below, the id of the product was buried within a ‘Product’ sub-array. The example grabs the id from the sub-array and places it on the top level array of the product so that the importer recognises the id.

function wpgetapi_modify_product_id( $items ) {
    foreach ($items as $i => $value) {
        if( isset( $value['Product']['id'] ) ) {
            $items[ $i ]['id'] = $value['Product']['id'];
        }
    }
    return $items;
}
add_filter( 'wpgetapi_api_to_posts_importer_items_before_save', 'wpgetapi_modify_product_id', 10, 1 );

Filter: wpgetapi_api_to_posts_get_item_for_mapping

This filter allows you to modify the id of the item that is used for mapping. The plugin simply looks at the first item (item 0) to create the mapping options and to display the preview data within the Mapping tab. Using this filter you can change which item is used for the mapping. This is useful if item 0 does not contain all of the data required to be mapped.

function wpgetapi_modify_mapping_item( $i ) {
    // setting to 1 returns the second item (0 is first item)
    return 1;
}
add_filter( 'wpgetapi_api_to_posts_get_item_for_mapping', 'wpgetapi_modify_mapping_item', 10, 1 );
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.