woocommerce offtopic - Absolute search against wordpress api

I am using the below to search to check if a product category is already created$params = ['search' => &quo

I am using the below to search to check if a product category is already created

$params = [
    'search' => "category1"
];
$searchedparaCat = $woocommerce->get('products/categories', $params);

using

This works however it seems to do searches as 'like' instead of absolute. For example the above could return

"category11", "category14", "category14552"....

What I need really is an absolute search so that it will ONLY return a category with the give search term as its slug. Is this possible? I know I can iterate over the returned results and filter them but before I go down that route can this be done via the api?

I am using the below to search to check if a product category is already created

$params = [
    'search' => "category1"
];
$searchedparaCat = $woocommerce->get('products/categories', $params);

using https://github/woocommerce/wc-api-php

This works however it seems to do searches as 'like' instead of absolute. For example the above could return

"category11", "category14", "category14552"....

What I need really is an absolute search so that it will ONLY return a category with the give search term as its slug. Is this possible? I know I can iterate over the returned results and filter them but before I go down that route can this be done via the api?

Share Improve this question asked May 28, 2019 at 20:25 DevWithZacharyDevWithZachary 1033 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Searches are always fuzzy, not exact. You might be looking for the slug parameter here. From the documentation, it reads Limit result set to resources with a specific slug.

I assume it should fit your case and it would only return the categories that match the slug provided.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745455214a4628454.html

相关推荐

  • woocommerce offtopic - Absolute search against wordpress api

    I am using the below to search to check if a product category is already created$params = ['search' => &quo

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信