A section of the PHP code that shows all the classifications wants to change to show specific categories.

Source: Internet
Author: User
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 is the current code. There is a table in my database that has a field that is term_id I have the term_id of the categories that need to be displayed $duqu inside I want to ask how to insert this variable into the above code can only show those selected term_id classification it?


Reply to discussion (solution)

You give the code at all can not find term_id and $duqu, how to help you change

Generally want to meet your requirements, pass a judgment on it!

You give the code at all can not find term_id and $duqu, how to help you change

Generally want to meet your requirements, pass a judgment on it!

Sorry, it's a little busy to come back to the post
Yes, that's the code that came with the program. I don't know what's going on with those term_id. The name of the variable may not be the same as it was from the database table.
I did a little research and found a solution, but there's one place that can't be bothered.

if (! In_array ($term->slug, Array ())) {
$new _terms[] = $term;
}

I used this program to make some categories not show for example, I don't want to show the classification of slug value A as an array (' a ') you can
But I don't think it shows a lot.
$SHAIXUANKUWP _terms=mysql_query ("select * from ' wp_terms ' where term_id= '". $duqu _term_id. "");
I've screened out all the rows I want to not show in this section.
while ($DUQUSHUJUKUWP _terms=mysql_fetch_array ($SHAIXUANKUWP _terms)) {$duqu _slug= $duqushujukuwp _terms[slug];}
This paragraph of my line read out the classification of the Slug
But I don't know how to put $duqu_slug this all into the above array () inside the array () it seems that arrays () can not be placed in the list only one
Help me see how to change it.

while ($DUQUSHUJUKUWP _terms=mysql_fetch_array ($SHAIXUANKUWP _terms)) {$duqu _slug[]= $duqushujukuwp _terms[slug];}

$duqu _slug is an array of rows you don't want to display.

while ($DUQUSHUJUKUWP _terms=mysql_fetch_array ($SHAIXUANKUWP _terms)) {$duqu _slug[]= $duqushujukuwp _terms[slug];}

$duqu _slug is an array of rows you don't want to display.
Thanks, but it's settled.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.