Get queried object for custom post type count

function wpse340250_term_count( WP_Term $term, $post_type) { $q_args = [ ‘post_type’ => $post_type, ‘nopaging’ => true, // no limit, pagination ‘fields’ => ‘ids’, // only return post id’s instead of full WP_Post objects will speed up ‘tax_query’ => array( array( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id, ), ), ]; $term_count = get_posts($q_args); return … Read more

How can I add image sizes for a specific custom post type?

You can try this (not tested): // Add image sizes for book outside add_image_size( ‘book_portrait_thumbnail’, ‘150’, ‘215’, true ); add_image_size( ‘book_portrait_square’, ‘300’, ‘300’, true ); // Delete all intermediate image sizes add_filter( ‘intermediate_image_sizes’, ‘custom_image_sizes’, 99 ); function custom_image_sizes( $image_sizes ) { //In case of book return book sizes array if( isset($_REQUEST[‘post_id’]) && ‘books’ === get_post_type( … Read more