php - json api controller for woocommerce category images -
I try to use json api to get some woocommerce data. Regularly with the WP Jason API, I can use the custom post type 'product' to get the most from my postcard, but I also need category data, such as names and special category pictures. For this I had to write a simple controller around the 'get_terms' package ('product_cat'). I'm sure that it lacks my php oop knowledge where I fail to add the key (image), value (image_url) As far as I am adding the final image pair details to my JSON, but I really want to find these details between all the other key values, as an image value for each category object.
< P> Here's my Controller: $ product_categories); }} Here is the result:
How do I add these image data to each productcags array or / or how to do it differently Standard JSON Like API methods, 'get_category_index' I honestly do not have any clue that it should use other than regaining the category index. It is also with the controller on which I have seen how the menu will return the index, but what I want to be able to get the values and the actual menu is being used. I'm sure I'm missing something here.
should be the administrator:
'1.0'); } Public function get_category_images () {$ args = array ('number' = & gt; $ number, 'orderby' = & gt; $ command, 'command' = & gt; $ command, 'hide_empty' = & gt; $ Hide_empty, 'included' = & gt; $ id); $ Product_categories = get_terms ('product_cat', $ args); Forex Currency ($ $ $ $ as CatCount) {// thumbnail ID user is term_ id $ thumbnail_id = get_woocommerce_term_meta ($ cat- & gt; term_id, 'thumbnail_id', true); // get image url $ image = wp_get_attachment_url ($ thumbnail_id); $ Cat & gt; {'Image'} = $ image; } Return Array ("WooCommerce Categories" => $ product_categories); }}
Comments
Post a Comment