Is it possible to get_terms by taxonomy AND post_type?

Here is another way to do something similar, with one SQL query: static public function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->prepare( “SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->posts AS p … Read more

Overriding an existing filter

This is the pattern for a filter. Applying/using a filter on something: $filtered_version = apply_filters( ‘the name of the filter’, $the_thing_being_filtered ); This is how you use a filter to modify something: add_filter( ‘the name of the filter’, ‘name_of_a_function_that_will_modify_the_thing_being_filtered’ ); function name_of_a_function_that_will_modify_the_thing_being_filtered( $the_thing_being_filtered ) { // modify $the_thing_being_filtered here return $the_thing_being_filtered; } So in your … Read more

Modify WordPress Search

You could try something like this below. Basically, if we are performing a search and it is the main_query (the query that generates the page results) ignore the default search and perform an exact match via the query_where function custom_product_search_exact_match( $query ) { global $wpdb; if ( is_search() && is_main_query() && !empty( $query->query_vars[‘s’] ) ) … Read more

Create a custom taxonomy’s term form

WordPress does not provide a hook or any API/function which allows us to move that form, or prevent it from being generated and added to the HTML source. But if you just wanted to visually hide that form, then it can easily be done using CSS, e.g. body.wp-admin.edit-tags-php #col-left { /* Hide the default form … Read more