get_queried_object not work in taxonomy page
get_queried_object not work in taxonomy page
get_queried_object not work in taxonomy page
You need to use action to get categories. in init action you can get product categories. add_action(‘init’, ‘my_product_cat’); function my_product_cat() { $woo_cat_args = array( ‘taxonomy’ => ‘product_cat’, ‘orderby’ => ‘name’, ‘hide_empty’ => 0, ); $woo_categories = get_categories( $woo_cat_args ); echo “<pre>”; print_r($woo_categories); echo “</pre>”; }
Get categories within specific term
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
Please check if any of the solutions work for you. There are a few ways we can try to achieve this. Through WP Permalinks Go to Settings >> Permalinks and select Custom and enter: /%category%/%postname%/ Next set your Category Base to . Through Yoast Plugin Go to Yoast SEO Select advanced Click on the tab … Read more
$catids = $_POST[‘artticle_category’]; /* * If the ids are coming from the database or another source, we would * need to make sure these were integers or convert them to interger using intval: */ $catids = array_map( ‘intval’, $catids ); $catids = array_unique( $catids ); $taxonomy = ‘articles_category’; $post_id = ‘1’; $term_taxonomy_ids = wp_set_object_terms( $post_id, … Read more
You can use wp_update_term to modify terms (even the default uncategorized) and wp_insert_term to update existing terms. Here is a basic example that should get you there. function add_category(){ // Update Uncategorized Category (1) wp_update_term( 1, ‘category’, array( ‘name’ => ‘New Category Name’, ‘slug’ => ‘new-category-slug’ ) ); // Insert New Category if(!term_exists(‘another-category’)) { wp_insert_term( … Read more
Add A CSS Class To A Menu Item When A Custom Taxonomy Term is Present On Single Post
Cloning product not copying custom taxonomies
By adding ‘orderby’ => ‘term_order’, line solved this issue. $terms = get_terms( array( ‘taxonomy’ => ‘cities’, ‘include’ => $cities, ‘orderby’ => ‘term_order’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0 ) );