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

column values not showing after merging two custom post types

The correct action hook for printing custom column content is manage_loads_posts_custom_column, not manage_invoices_posts_custom_column (tested). This is because the row is itself for a loads post type, and not an invoices post type. Because you’re on the page for invoices, the filter to add columns works with invoices. Tested: add_action( ‘manage_loads_posts_custom_column’, ‘invoice_custom_column’, 10, 2 ); I … Read more

Compare a CPT post with a normal post

I tried to write something like this, but set in the functions of child theme I got php error: I know there are bugs here but I say ‘something like this’ $current_title = get_the_title(); $post = new WP_Query( array( ‘post_type’ => ‘attivita’, ‘posts_per_page’ => -1 ) ); function get_the_title( $post = 0 ) { $post … Read more

How to add capability to author role to assign custom taxonomy terms to a custom post type?

Yes. It is some kind of mapping. So now, when I register the custom taxonomy I pass it: $caps = array( ‘manage_terms’ => ‘activate_plugins’, ‘edit_terms’ => ‘activate_plugins’, ‘delete_terms’ => ‘activate_plugins’, ‘assign_terms’ => ‘edit_posts’ ); With this result authors can now assign terms. I am just using ‘activate_plugins’ because, by default, authors do not have this … Read more