WordPress tax_query “and” operator not functioning as desired

not tested but give this a shot ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘image_tag’, ‘field’ => ‘term_id’, ‘terms’ => 25, ‘operator’ => ‘IN’, ), array( ‘taxonomy’ => ‘image_tag’, ‘field’ => ‘term_id’, ‘terms’ => 41, ‘operator’ => ‘IN’, ) ), OR ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘image_tag’, ‘field’ => … Read more

How do I append multiple taxonomies to the URL?

This is certainly possible by utilizing some rewrite rules of your own to some extent. The WP_Rewrite API exposes functions that allow you to add rewrite rules (or ‘maps’) to convert a request to a query. There are prerequisites to writing good rewrite rules, and the most important one is basic regular expression comprehension. The … Read more

How to Add Custom Taxonomy To Woocommerce Plugin

You have to do: add_action( ‘init’, ‘custom_taxonomy_Item’ ); Because: Use the init action to call this function. Calling it outside of an action can lead to troubles. see codex page register_taxonomy. Besides that : Better be safe than sorry when registering custom taxonomies for custom post types. Use register_taxonomy_for_object_type() right after the function to interconnect … Read more

How to add images to taxonomies?

Starting from WordPress 4.4, you can use add_term_meta function to store metadata for a term. This is basically a key-value pair information which is stored in wp_termmeta table. Original Answer(Prior to WP 4.4) WordPress doesn’t have the option to add extra information to taxonomies. There isn’t any taxonomy_meta table. So, you have two options. Create … Read more

Count posts in custom taxonomy

Use an instance of WP_Query to query the database. http://codex.wordpress.org/Class_Reference/WP_Query To query database for custom taxonomies use, $query = new WP_Query( array( ‘people’ => ‘bob’ ) ); For more details on available options see: Taxonomy Parameters http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters Retrieve published posts using ‘post_status’ => ‘publish’ Use found_posts to retrive the number of posts $count = $query->found_posts;

Custom Post Type Permalink / Rewrite not working immediately

Use the function flush_rewrite_rules() for set the rewrite rules new, but not with your code on init-hook, only on activation plugin or theme! See more in my post: http://wpengineer.com/2044/custom-post-type-and-permalink/ global $wp_rewrite; $wp_rewrite->flush_rules(); Flush rules only on activation (and deactivation). Don’t do it on any other hook. register_activation_hook()