wordpress - php - Get name and slug from category -
I found this function:
slug)! {Array_push ($ categories, $ category_list_item- & gt; slug); }} Foreach ($ categories as $ range) {$ args = array ('post_type' = & gt; 'product', 'posts_per_page' => 100, 'product_cat' = & gt; $ range, 'orderby '= & Gt;' Rand '); ? & Gt;
This is good, it gives a class slag for me in a loop The problem is, now I can not get the name of the category now. I tried to add another array: '$ names = [];' And if I but I did not take it along with all the solutions I have tried, I just return the 'array' to the full list of names. Is anyone's solution?
Thank you!
& lt;? Php $ ranges = array (); $ Names = array (); $ Category_list_items = get_terms ('product_cat'); Foreign currency ($ category_list_items as $ category_list_item) {if (empty ($ category_list_item-> slug)) {$ categories [] = $ category_list_item-> Slog; $ Name [] = $ category_list_item-> Name; }} Foreach ($ ranges as dollar categories = & gt; $ range) {resonant "category name:". $ Names [$ key]; Echo "Category Slug:". $ Range; $ Args = array ('post_type' = & gt; 'product', 'posts_per_page' => 100, 'product_cat' = & gt; $ range, 'orderby' = & gt; 'rand'); ? & Gt;
Comments
Post a Comment