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

How to associate custom taxonomy terms with custom post type?

$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

Create category after theme setup and modify the default one

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

Can’t display posts by filtering categories using isotope.js

Can you try: <?php if (have_posts()): ?> <?php while (have_posts()): the_post(); ?> <?php $categories = get_the_category(); $listCategories = []; foreach ($categories as $category) { $listCategories[] = $category->slug; } ?> <!– Isotope Grid-Item –> <div class=”col-md-3 col-sm-4 col-xs-12 isotope-grid-item <?php echo implode(‘ ‘, $listCategories); ?>” data-category=”<?php echo implode(‘,’, $listCategories); ?>”> <div class=”isotope-item”> <a href=”#”> <div class=”isotope-feature-image”><?php … Read more

Order get_terms by count using a custom taxonomy hierarchy

Don’t know if it’s the best solution but I ended up using a custom query to show all categories ordered by count. $cats = $wpdb->get_results(” select tt.term_id, count, name, slug from “.$wpdb->prefix.”term_taxonomy as tt inner join “.$wpdb->prefix.”terms as terms on tt.term_id = terms.term_id where taxonomy = ‘product_cat’ order by count desc limit 10 “); echo … Read more