How to check if I’m on a custom post type archive in the admin area

Here are three possibilities, based on the /wp-admin/admin.php file: Method #1 There are the global $pagenow and $typenow available: global $pagenow, $typenow; if( ‘my_venue’ === $typenow && ‘edit.php’ === $pagenow ) { // … } Method #2 Then there’s the current screen, also set in the admin.php file with set_current_screen(); $screen = get_current_screen(); if( is_a( … Read more

Defining capabilities for custom post type

You code seems to be correct. Try the following instead. $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => true, ‘hierarchical’ => false, ‘menu_position’ => null, ‘supports’ => array(‘title’), ‘capability_type’ => ‘video’ ); Update: You have to do some extra steps before making it … Read more

Taxonomy count per Post type

I needed to get the number of post per type per term so i created this small function: function get_term_post_count_by_type($term,$taxonomy,$type){ $args = array( ‘fields’ =>’ids’, //we don’t really need all post data so just id wil do fine. ‘posts_per_page’ => -1, //-1 to get all post ‘post_type’ => $type, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more