Terms change id after importing

Off the top of my head, you’d have to either: (a) bypass the import functionality in WP and do it direct to the database, so the term IDs stay the same (i.e. export/import from phpMySQL). or (b) write a “run once” data migration function to update your term IDs once they’re imported, using a reference … Read more

Add attribute taxonomy through code don’t appear in admin product page

the solution is: foreach ($attributes as $attr => $value) { $attr=”pa_”.$attr; wp_set_object_terms($post_ID, $value, $attr); $thedata[sanitize_title($attr)] = Array( ‘name’ => wc_clean($attr), ‘value’ => $value, ‘postion’ => ‘0’, ‘is_visible’ => ‘1’, ‘is_variation’ => ‘1’, ‘is_taxonomy’ => ‘1’ ); } update_post_meta($post_ID, ‘_product_attributes’, $thedata);

Custom permalink accept any params

This is, I suppose, just how the query parser works. If you create a new WP_Query instance, and provide a post name, any taxonomy parameters you add will be ignored and will not be added to the query. Post uniqueness is determined entirely based on post slug, and uniqueness of slug is enforced. It’s possible … Read more

How to list the taxonomy terms that fit the custom query?

Get this recipe’s assigned terms (recipe having $recipe_id): $terms_arr = []; $terms_objs = get_the_terms($recipe_id, ‘main_ingredient’); if ($terms_objs) { foreach ($terms_objs as $term_obj) { $terms_arr[] = $term_obj->slug; } } Find the terms found in both arrays: $the_ingrediens = array_intersect($ingredients, $terms_arr);

Remove taxonomy widget from “PAGE” post

In your register_taxonomy() args, set meta_box_cb => false ‘meta_box_cb’ (bool|callable) Provide a callback function for the meta box display. If not set, post_categories_meta_box() is used for hierarchical taxonomies, and post_tags_meta_box() is used for non-hierarchical. If false, no meta box is shown. $args = array( //other args ‘meta_box_cb’ => false, ); register_taxonomy( $args );

Dynamically set taxonomy term and show admin notice on post save

Okay, so just in case anyone needs help on the same thing I did… here is my solution. Instead of a php/wordpress solution, I used javascript. Id love to see the php/wordpress solution if someone wants to post it. <?php // Admin Custom JS add_action(‘admin_head’, ‘admin_custom_js’); function admin_custom_js() { ?> <script> // update date (month) … Read more

Show only the sub-categories (and their content) of the current custom taxonomy with ‘taxonomy.php’

I think you can easily achieve that if you understand WordPress template hierarchy. Looking at the template hierarchy diagram, and assuming you have categories and sub-categories, then you can achieve what you want in multiple ways. Suggestion 1 Use category.php to display the posts of any category, including sub-categories. also in category.php add a condition … Read more