Remove Content Template and Template Layout metabox from CPT

Problem:
Remove ‘Content Template’ and ‘Template Layout’ widgets/metabox for certain CPT in admin screen (WP post edit screen).

Solution:
Please add this code in your theme’s or child theme’s functions.php file:


add_action( 'admin_head', 'wpv_custom_admin_head', 20);
function wpv_custom_admin_head() {
remove_meta_box( 'wpddl_template', 'book', 'side' ); // replace book with your CPT slug
remove_meta_box( 'views_template', 'book', 'side' ); // replace book with your CPT slug
}

==> Whereas ‘book’ should be replaced with your CPT slug.

Relevant Documentation:
https://codex.wordpress.org/Function_Reference/remove_meta_box

Count Repeating Field / Count multiple instances

We can achieve this by using custom shortcode. Please add this code in your theme’s or child theme’s functions.php file:


add_shortcode( 'count-repeats', 'count_repeat_func' );
function count_repeat_func($atts) {
return sizeof(get_post_meta( $atts['post-id'], 'wpcf-' . $atts['field'], false ));
}

Then you can use this ShortCode. You should wrap this ShortCode in an HTML Conditional to check if the Field does exist, as other wise unexpected results can be produced:

[count-repeats post-id="6184" field="url"]

More details: https://wp-types.com/forums/topic/how-to-count-repeated-field/#post-412707