How can I order a post query’s results based on the number of matching taxonomy terms?
How can I order a post query’s results based on the number of matching taxonomy terms?
How can I order a post query’s results based on the number of matching taxonomy terms?
For some reason the add_action( ‘pre_get_posts’, ‘category_custom_orderby’ ); hook isn’t working. Yes, and it’s because on the Categories admin page (where you can see the Categories list table), the list table uses WP_Term_Query and not WP_Query, hence the above hook (pre_get_posts) is not fired. So instead of the above add_action(), try using the parse_term_query hook … Read more
wp_insert_term doesn’t want to enter its data into custom taxonomy
I figured it out: update_term_meta( $term_id, ‘organization’, $_POST[‘organization’], true ); should have been update_term_meta( $term_id, ‘organization’, $_POST[‘organization’] ); Where the fourth parameter makes it unique.
automatically select taxonomy based on post meta
So I came up with a workaround solution. Not sure if it is the fastest and best solution but it works perfectly fine for our custom field. This works with custom post types and custom taxonomies and sorts everything A->Z. Any better solution? // get all posts from custom post type and their TERMS // … Read more
If you have a need to build up an actual structure of terms, this might be a useful method for you: /** * Recursively sort an array of taxonomy terms hierarchically. Child categories will be * placed under a ‘children’ member of their parent term. * @param Array $cats taxonomy term objects to sort * … Read more
PHP Warning: Attempt to read property “slug” on bool in tax query
Get Terms of custom Taxonomy of products with certain Product Category
set_object_terms action hook based on the function in the published CPT