Using get_terms() with meta_query parameters

Inserting boolean term meta values When we add non-existent term meta with e.g. add_term_meta( 123, ‘test’, true ); then we are actually running the following insert : $wpdb->insert( ‘wp_termmeta’, array( ‘term_id’ => 123, ‘meta_key’ => ‘test’, ‘meta_value’ => true ) ); within the general add_metadata() function. Now wpdb::insert() is actually a wrapper for wpdb::_insert_replace_helper() that … Read more

Restrict filter to run only inside specific function

wp_terms_checklist early trigger a filter ‘wp_terms_checklist_args’ so you can use that filter to add your filter and auto-remove it haver 1st run. This should be enough, however, once hooks are global variables, to be sure is better use some stronger check, a static variable inside a function is a simple and nice trick: function switch_terms_filter( … Read more

have_posts() return false but count says “3”

I had same problem. According to documentation: The hierarchy for a custom taxonomy is listed below: taxonomy-{taxonomy}-{term}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php So, it doesn’t matter witch template file you are using, all of them will generate same issue. When I put in the beginning of template file code var_dump($wp_query);, i found this: public ‘request’ => … Read more

Display certain amount of posts on taxonomy archive page

Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates? (Yes I know I also make queries in my templates but wanted to help out before leaving office) function wpse214084_max_post_queries( $query ) { if(is_tax(‘genre’)){ // change genre into your … Read more

Looping Through Custom Tax Terms and Displaying All Posts For Each

If your things are laid properly, this code will output 10 posts from film CPT, where taxonomy is category-film and it will occur each of the term of that particular taxonomy. I’m not aware about your templating, so lay your layout accordingly. <?php $_terms = get_terms( array(‘category-film’) ); foreach ($_terms as $term) : $term_slug = … Read more