2017 © Pedro Peláez
 

library wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

image

moxie-lean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  • Monday, June 13, 2016
  • by mitogh
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,057 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

WP Endpoint Collection

This package is depreciated. LEAN now uses the WordPress REST API plugins instead, (*1)

Query against a WordPress site and get a JSON response with a collection of data associated with your request., (*2)

Getting Started

The easiest way to install this package is by using composer from your terminal:, (*3)

composer require moxie-lean/wp-endpoints-collection

Or by adding the following lines on your composer.json file, (*4)

"require": {
  "moxie-lean/wp-endpoints-collection": "dev-master"
}

This will download the files from the packagist site and set you up with the latest version located on master branch of the repository., (*5)

After that you can include the autoload.php file in order to be able to autoload the class during the object creation., (*6)

include '/vendor/autoload.php';

\Lean\Endpoints\Collection::init();

Features

  • Avoid to query post that are on draft, private or any other state that is not publish.
  • Avoid to query post with passwords protections.

By default returns only a collection of posts but any post type can be specifed to be returned or a collection of multiple post types can be specifed as well., (*7)

Usage.

The default URL is:, (*8)

```` /wp-json/leean/v1/collection, (*9)


By default the collection is the list of posts, you can use most of the WP_Query params in order to update your results, for example by default uses setting that specifies the number of reading post on the settings page. ## Request examples Get only the latest 3 posts. ```json wp-json/leean/v1/collection?posts_per_page=3

How about get the latest 3 posts that belongs to the author with the ID 1., (*10)

wp-json/leean/v1/collection?posts_per_page=3&author=1

Or just get the posts that belong to the author with the ID 1., (*11)

wp-json/leean/v1/collection?author=1

Get the all the posts ordered by ID from lowest to highest values., (*12)

wp-json/leean/v1/collection?orderby=ID&order=ASC

Get all the posts and pages published on the site., (*13)

wp-json/leean/v1/collection?post_type[]=post&post_type[]=page

Get the first and second page of the blog section., (*14)

wp-json/leean/v1/collection
wp-json/leean/v1/collection?paged=2

Get all the posts that has the category ID 2, (*15)

wp-json/leean/v1/collection?cat=2

Filters

There are filters that can be used on this particular endpoint., (*16)

ln_endpoints_collection_args. This filter allow you to overwrite the default arguments used to query inside of the collection so you can overwrite the default values used on the WP_Query before executed., (*17)

ln_endpoints_collection_data. This filter allow you to overwrite the data after processing and before is sending it to the client it has 1 parameter that can be used on the filter:, (*18)

  • $data The original data created by the endpoint, this is an array with all the data, for example if you want to return an empty array if the data has zero items., (*19)

  • $request An array with the arguments used to create the request., (*20)

add_filter('ln_endpoints_collection_data', function( $data ){
  if ( isset( $data['pagination']['items'] ) && $data['pagination']['items'] === 0 ) {
    return [];
  } else {
    return $data;
  }
});

ln_endpoints_collection_item. Allows you to easily customise the output of each post:, (*21)

add_filter( 'ln_endpoints_collection_item', function($item, $the_post) {
      if ( $the_post->ID === 1 ) {
        return [
         'message' => 'Nothing here',
        ];
      } else {
        return $item;
      }
    }, 10, 2);;

The Versions

13/06 2016

dev-master

9999999-dev https://github.com/moxie-lean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

13/06 2016

1.2.0

1.2.0.0 https://github.com/moxie-lean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

27/04 2016

1.1.0

1.1.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

27/04 2016

1.0.2

1.0.2.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

26/04 2016

1.0.1

1.0.1.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

25/04 2016

1.0.0

1.0.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

22/04 2016

0.4.1

0.4.1.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

22/04 2016

0.4.0

0.4.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

20/04 2016

0.3.2

0.3.2.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

19/04 2016

0.3.1

0.3.1.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

19/04 2016

0.3.0

0.3.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

15/04 2016

0.2.1

0.2.1.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

13/04 2016

dev-meta

dev-meta https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

05/04 2016

0.2.0

0.2.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api

31/03 2016

0.1.0

0.1.0.0 https://github.com/moxie-leean/wp-endpoints-collection

Query against a WordPress site and get a JSON response with a collection of data associated with your request.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Moxie Developers

wordpress wordpress api