Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LIKE operator to Tax_Query in Tainacan API #266

Closed
leogermani opened this issue Jun 5, 2019 · 2 comments

Comments

@leogermani
Copy link
Contributor

commented Jun 5, 2019

This issue comes from the discussion on #236

It sounds like a good idea to add support to do a LIKE search to the Tax_Query. It could be useful in many situations, giving more flexibility to filters and to an advanced search

This will be implemented using the approach tested here:

public function transform_meta_query_to_tax_query($args) {

Note that this change will be applied only to the Tainacan API and not to the WP_Query class in general

@leogermani

This comment has been minimized.

Copy link
Contributor Author

commented Jul 29, 2019

Added support in the API

Now the API supports LIKE as a value for the operator parameter in tax_query statements.

Example

$request  = new \WP_REST_Request('GET', $this->namespace . '/collection/' . $collection->get_id() . '/items');
		
$attributes = [
	'taxquery' => [
		[
			'taxonomy' => $taxonomy->get_db_identifier(),
			'operator' => 'LIKE',
			'terms' => 'water'
		]
	]
];
		
$request->set_query_params($attributes);
$response = $this->server->dispatch($request);

We have to make sure to add this to the api docs somehow

@leogermani leogermani moved this from To Do to Validation in tainacan/tainacan Jul 29, 2019

@leogermani

This comment has been minimized.

Copy link
Contributor Author

commented Jul 30, 2019

We will alson need support to the equivalent NOT LIKE operator.

  • add support to NOT LIKE operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.