A section of php code that shows all categories. if you want to change it to display a specific category, you can find add_filter ('Get _ terms ', 'get _ subcategory_terms', 10, 3 );
Function get_subcategory_terms ($ terms, $ taxonomies, $ args ){
$ New_terms = array ();
If (in_array ('product _ cat', $ taxonomies )&&! Is_admin () & is_shop ()){
Foreach ($ terms as $ key => $ term ){
$ New_terms [] = $ term;
}
$ Terms = $ new_terms;
}
Return $ terms;
}
This section is the current code. in my database, there is a table with a field term_id. I have saved the term_id of the category to be displayed in $ duqu. I want to ask how to insert this variable to it. only the selected term_id categories can be displayed in the code. thank you.
Reply to discussion (solution)
The code you provided cannot find term_id and $ duqu.
If you want to meet your requirements, just pass a judgment!
The code you provided cannot find term_id and $ duqu.
If you want to meet your requirements, just pass a judgment!
Sorry, I just came back to read my post.
The code is included in the program. I don't know much about the term_id and so what I export from the database table. so the variable names may be different.
I found a solution after studying it, but there is something difficult to solve. Please check if you will thank me.
If (! In_array ($ term-> slug, array ())){
$ New_terms [] = $ term;
}
I used this program to make some categories not displayed. for example, if I don't want to display A slug value as A classification, I can write it as array ('A ').
But I don't think there are many
$ Shaixuankuwp_terms = mysql_query ("SELECT * FROM 'WP _ terms 'where term_id ='". $ duqu_term_id ."'");
This section filters out all rows in the table that I want not to display.
While ($ duqushujukuwp_terms = mysql_fetch_array ($ shaixuankuwp_terms) {$ duqu_slug = $ duqushujukuwp_terms [slug];}
I read the slug of the classification in one row.
But I don't know how to put $ duqu_slug in the above array (). It seems that the array () cannot be put in one row.
Code placement to help you see how to change it. thank you.
While ($ duqushujukuwp_terms = mysql_fetch_array ($ shaixuankuwp_terms) {$ duqu_slug [] = $ duqushujukuwp_terms [slug];}
$ Duqu_slug is the array of rows you do not want to display.
While ($ duqushujukuwp_terms = mysql_fetch_array ($ shaixuankuwp_terms) {$ duqu_slug [] = $ duqushujukuwp_terms [slug];}
$ Duqu_slug is the array of rows you do not want to display.
Thank you.