Giter Site home page Giter Site logo

jp-tax-query's Introduction

JP Tax Query

Adds a tax_query endpoint to the jp-api route or the WordPress REST API (WP-API). You can pass, in the body of the request a tax_query. See the codex for information on how to make one of those. The request's body can have 'post_type' and 'tax_query' arguments only. All other arguments will be stripped out before passing to WP_Query so don't try it.

This endpoint does NOT require authentication. Please consider whether or not you really want the whole internet to be able to run tax queries on your site before using.

TL;DR

The REST API only lets you filter by one term per taxonomy. This gives you all of the powers of tax_queries.

Change name of route?

define( 'JP_API_ROUTE', 'skywalker' );

Endpoint is now skywalker/tax_query

Installation

This is not a plugin.

The correct way to add it is to add "shelob9/jp-tax-query": "dev-master" to your site/plugin/theme's composer.json. Include composer autoloader.

Alternatively, add this repo to your site/plugin/theme using a Git Submodule or by employing the dark art of copypasta.

Usage

    $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    		'relation' => 'AND',
    		array(
    			'taxonomy' => 'movie_genre',
    			'field'    => 'slug',
    			'terms'    => array( 'action', 'comedy' ),
    		),
    		array(
    			'taxonomy' => 'actor',
    			'field'    => 'id',
    			'terms'    => array( 103, 115, 206 ),
    			'operator' => 'NOT IN',
    		),
    	),
    );
    $response = wp_remote_get( json_url( 'jp-api/tax-query') , array( 'body' => json_encode( $args ) ) );

License

Copyright 2014 Josh Pollock. Licensed under the terms of the GNU General public license version 2. Please share with your neighbor.

jp-tax-query's People

Contributors

shelob9 avatar

Stargazers

emily dela cruz avatar  avatar John Parris avatar

Watchers

James Cloos avatar John Parris avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.