delete category on plugin deactivation wordpress

You should save that category id in option table instead of set as global. Try below code which is helps you to delete that category on deactivation hook. function add_category_on_activation(){ $wpdocs_cat = array(‘cat_name’ => ‘Event Category’, ‘category_description’ => ‘An Event Category to show all events’, ‘category_nicename’ => ‘events’, ‘category_parent’ => ”); $wpdocs_cat_id = wp_insert_category($wpdocs_cat); if($wpdocs_cat_id) … Read more

how do you pull data from two taxonomies?

First, get all term slugs from the custom example taxonomy space by current post ID. $space_terms = wp_get_post_terms( $post->ID, ‘space’ ); if( $space_terms ) { $space_terms = array(); foreach( $space_terms as $term ) { $space_terms[] = $term->slug; } } You should specify the logical relationship between each inner taxonomy array when there is more than … Read more

Update a list of product to featured if product have meta value (Mysql not wpquery)

Ok I’v created a admin plugin to do this… If you have better idea 🙂 I’m in Create a admin button to open a csv file of meta_value to compare with existing products. and update products as featured if exist. add_action(‘admin_menu’, ‘featured_button_menu’); function featured_button_menu() { add_menu_page(‘Featured Products Page’, ‘Mise en avant produits’, ‘manage_options’, ‘featured-button-slug’, ‘featured_button_admin_page’); … Read more

What is the use case for sharing a term between multiple taxonomies?

The helpful folks on WordPress IRC pointed me to this article, which answered my question: https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ In WordPress 4.2, shared taxonomy terms – those items in the wp_terms table that are shared between multiple taxonomies – will be split into separate terms when one of the shared terms is updated. This change (31418) fixes one … Read more

Display related terms from a taxonomy in an entry

Please specify where are you using the code above, if in a template file or in a function. Assuming the code above is for a single post and that you’re trying to retrieve the dormitorio terms associated with that post you should use get_the_terms() instead of get_terms(). get_terms() Retrieves the terms in a given taxonomy … Read more

Template taxonomy-{taxonomy}.php doesn’t show my posts

Well, first of all, you are not doing anything with the $term variable. You are querying it, but then it sits there, waiting to be picked up. Try this code in your taxonomy template, called taxonomy-hardware_category.php: // prepare the variables for the query $tax = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); // Setup the loop, build the … Read more