PHPackages                             reactmore/wordpress-rest-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. reactmore/wordpress-rest-api-client

ActiveLibrary[API Development](/categories/api)

reactmore/wordpress-rest-api-client
===================================

Wordpress Rest Api Client PHP

1.07(4y ago)022PHPPHP ^7.0 | ^8.0

Since Jul 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/reactmore/wordpress-rest-api-client)[ Packagist](https://packagist.org/packages/reactmore/wordpress-rest-api-client)[ RSS](/packages/reactmore-wordpress-rest-api-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

wordpress-rest-api-client
=========================

[](#wordpress-rest-api-client)

> A Wordpress REST API client for PHP

Installation
------------

[](#installation)

This library can be installed with [Composer](https://getcomposer.org):

```
composer require reactmore/wordpress-rest-api-client

```

Usage
-----

[](#usage)

Example:

```
require 'vendor/autoload.php';

$client = new Reactmore\WordpressClient\Wordpress(new Reactmore\WordpressClient\Request\GuzzleAdapter(new GuzzleHttp\Client()), 'http://domain.com');

// iF WP API DISABLE YOU NEED TO PASS AUTH
// $client->setCredentials(new Reactmore\WordpressClient\Auth\WpBasicAuth('user', 'password'));

// Argument 1 id default Null
// Argumend 2 Array default Null
$posts = $client->posts()->get(1, ['params' => 'Key']);

echo '';
print_r($posts);
echo '';
```

Response Success:

- status = status name
- code = status Code
- data = callback data from wordpress
- X-WP-TOTAL = count all post on current result
- X-WP-TOTAL-PAGE = count all page on current result

```
Array
(

    [status] => success
    [code] => 200
    [data] => Array(

        id =>
        slug =>
        xxxx
    )
    [X-WP-TOTAL] => 6909
    [X-WP-TOTAL-PAGE] => 70

)

```

Response Error:

- status = status name
- code = status Code
- error = error message

```
Array
(

    [status] => failed
    [code] => 400
    [error] => Array(

        message =>

    )

)

```

Addon Custom Route
------------------

[](#addon-custom-route)

Insert On Functions Your Theme

```
function custom_api_get_all_posts()
{
    register_rest_route('custom/v1', '/all-posts', array(
        'methods' => WP_REST_Server::READABLE,
        'callback' => 'custom_api_get_all_posts_callback'
    ));
}

// custom Route API
function custom_api_get_all_posts_callback(WP_REST_Request $request)
{

    $posts_data = array();

    $paged = $request->get_param('page');
    $paged = (isset($paged) || !(empty($paged))) ? $paged : 1;

    $author = $request->get_param('author');
    $author = (isset($author) || !(empty($author))) ? $author : '';

    $search = $request->get_param('search');
    $search = (isset($search) || !(empty($search))) ? $search : '';

    $after = $request->get_param('after');
    $after = (isset($after) || !(empty($after))) ? $after : '';

    $before = $request->get_param('before');
    $before = (isset($before) || !(empty($before))) ? $before : '';

    $query = new WP_Query(
        array(
            's' => $search,
            'author' => $author,
            'paged' => $paged,
            'post__not_in' => get_option('sticky_posts'),
            'posts_per_page' => 10,
            'post_type' => array('post'),
            'date_query'          => array(
                //set date ranges with strings!
                'after' => $after,
                'before' =>  $before,

            ),
            'orderby' => 'date',
            'order'   => 'DESC'

        )
    );

    // if no posts found return
    if (empty($query->posts)) {
        return array();
    }

    // set max number of pages and total num of posts
    $max_pages = $query->max_num_pages;
    $total = $query->found_posts;

    $posts = $query->posts;

    // prepare data for output
    $controller = new WP_REST_Posts_Controller('post');

    foreach ($posts as $post) {

        $response = $controller->prepare_item_for_response($post, $request);
        $post_data = $controller->prepare_response_for_collection($response);
        $post_thumbnail = (has_post_thumbnail($post_data['id'])) ? get_the_post_thumbnail_url($post_data['id']) : null;

        $data[] = (object) array(
            'id' => $post_data['id'],
            'date' => $post->post_date,
            'author' => array(
                'id' => $post->post_author,
                'name' => get_the_author_meta('user_nicename', $post->post_author),
             ),
            'type' => $post->post_type,
            'title' => $post->post_title,
            'url' => get_permalink($post_data['id']),
            'content' => $post_data['excerpt']['rendered'],
            'featured_img_src' => $post_thumbnail,
            'meta' => get_post_meta($post_data['id'], '', '')

        );
    }

    // set headers and return response
    $response = new WP_REST_Response($data, 200);

    $response->header('X-WP-Total', $total);
    $response->header('X-WP-TotalPages', $max_pages);

    return $response;
}
```

Parameter :

- page = page your data
- author = filter by author id or name
- search = search post like search on API Post v2
- after and Before = Filter date Range better use Format d-f-y on query string or string on backend logic

Screenshoot
-----------

[](#screenshoot)

[![Backend](https://raw.githubusercontent.com/reactmore/wordpress-rest-api-client/master/preview.jpg)](https://raw.githubusercontent.com/reactmore/wordpress-rest-api-client/master/preview.jpg)Implementations Paginations

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

3

Last Release

1733d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3570cc985c6b8a72d6c662e81a23ef79c03cea6b4ad9e82da64365a5a641afe5?d=identicon)[reactmore](/maintainers/reactmore)

---

Top Contributors

[![reactmore](https://avatars.githubusercontent.com/u/64960434?v=4)](https://github.com/reactmore "reactmore (30 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/reactmore-wordpress-rest-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/reactmore-wordpress-rest-api-client/health.svg)](https://phpackages.com/packages/reactmore-wordpress-rest-api-client)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[php-heroku-client/php-heroku-client

A PHP client for the Heroku Platform API

24404.8k4](/packages/php-heroku-client-php-heroku-client)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)[trycourier/courier

Courier PHP SDK

16643.9k](/packages/trycourier-courier)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
