I am currently using the wordpress V2 API and trying to read posts based on categories. The problem I have is that in the GET request the categories are linked with OR instead of AND.
/v2/posts?per_page=5&page=1&categorie=1973,94&categories_exclude=1734,1032&_embed
This means that when I specify two categories, posts come back with only one of the two categories. I don't want that, I'm only interested in the posts that have both categories.
Can someone help me here?
Related
there's this great plugin that you can put selling points to all products on the store but the problem is that you can't specify categories or products to show it it just shows the same ones everywhere. I tried finding an alternative - even a paid version and i can't. Does anyone know of alternatives or can you tell me how to modify it to specify categories at least?
https://wordpress.org/plugins/woo-usp/
It's not working as I would like to, and as i have seen online many people have the same issue, you can't specify products or categories that you can post the information on
I have a number of different post types attached to various posts of type person through various fields (for example: contributors, editors, proofreading). I was wondering if there is any way to find all the posts attached to each person in reverse, or is it necessary to query every possible relationship field one by one?
Basically, I'm wondering if there's any kind of wp_query that can be built that results in 'Find every post that post X has been related to'.
If you've used the relationship field for ACF you can do a reverse query. ACF has a tutorial on their website that covers the details - https://www.advancedcustomfields.com/resources/querying-relationship-fields/
I want to get bestselling and favorites products from woocommerce site with rest API .
I read this site but not found any thing about that.
Does it exist any way to get that ?
For People Who are Still Stumbling upon this Question
As per WC v3 API. You can now pull Most Popular products through the API (which is the best selling product list as per my understanding);
GET /wp-json/wc/v3/products?orderby=popularity&order=desc
This should get you the most popular products in descending order by the number of sales. This is not currently documented (as of Feb 2, 2021).
Total list of possible orderby params are: date, id, include, title, slug, modified, menu_order, price, popularity, rating
Another part of the question asks for Favorite product API, which woo commerce doesn't have.
I can see that you can access bestsellers through reports. See here. As for favourites, I think this is done using third party plugins or custom code so I'm not sure how you are going to access this. But if I was to hazard a guess I would probably assume it would be under customer meta
In the latest version of Woocommerce API, (the WP REST API v2), the filters have been removed. Earlier I was using the following URL to get products ordered by their average_rating.
products?search=helloWorld&order=desc&filter[orderby]=meta_value_num&filter[orderby_meta_key]=_wc_average_rating
Now since filters have been removed, I am struggling to get the same output without using filters. I could not find anyway to order products according to their rating. I am also aware of the REST Filter Plugin but before going forward that direction, I want to make sure if there is an alternative way.
Any help is highly appreciated.
Change from orderby_meta_key to meta_key
Final code will be as:
products?search=helloWorld&order=desc&filter[orderby]=meta_value_num&filter[meta_key]=_wc_average_rating
For a WordPress project I'm looking for a better solution to this problem:
The query should get a set of different post_types and taxonomies (like categories), based on the site visitors choice. For example, the user want to get results from normal posts, but also products (from WooCommerce) and other post_types like events and news (both separate post_types. The tricky part is, that the user wants to assign a weight factor to each. So if they select like posts = 1, products = 3, news = 4, they should get a number of posts, three times more products and 4 times more news.
Next step will be to include categories, also with the weight factor, which will make it even more complex, because for posts, I need to query another taxonomy than for products.
The only way I found to solve this, is to run a separate query for each post_type, like fetching 10 items from posts, 30 items from products and 40 from news, to match the weight factors, then combine the results. But this will not scale very well when I need pagination (for example, I want to show 50 entries on the first page, next 50 on second page).
I thought about collecting these single queries into a temporary table, but such a table will be available for the current session only, so it won't help with the pagination (as the temporary table would no longer exist, when the second page is shown).
Does anybody have an idea, how I could approach this task? I would like it according to the WordPress coding standards, so I would like to use WP_Query and the provided filters, because the site is also using geolocating and WPML for translation, so I really would like to avoid writing a low-level query where I have to include all these manually.
I'm not looking for a final solution, just want to collect some ideas.