Count posts by type including drafts and pending posts

It’s not necessary to use $wpdb, a simple get_posts can handle it. Check WP_Query for the full list of parameters. function count_user_posts_by_type( $userid, $post_type ) { $args = array( ‘numberposts’ => -1, ‘post_type’ => $post_type, ‘post_status’ => array( ‘publish’, ‘private’, ‘draft’, ‘pending’ ), ‘author’ => $userid ); $count_posts = count( get_posts( $args ) ); return … Read more

Admin – create custom post status and display above table

You can use the answer given here: How to add a quicklink to the Posts Admin Published|Scheduled|Trash menu For e.g. Stephen Harris answered the same question to add an extra menu item for displaying today’s posts. add_filter( ‘views_edit-post’, ‘wpse_add_my_view’); function wpse_add_my_view($views){ global $post_type_object; $post_type = $post_type_object->name; $y =mysql2date(‘Y’, current_time(‘mysql’) ); $m =mysql2date(‘m’, current_time(‘mysql’) ); $d … Read more

Get publish post link?

I used URL parameters and created a specific function called at init: add_action( ‘init’, ‘publish_post_status’ ); function publish_post_status($post_id){ if (isset($_GET[‘publish’]) && current_user_can(‘publish_posts’)) { if ($_GET[‘publish’] == “true”) { $current_post = get_post( $_GET[‘post_id’], ‘ARRAY_A’ ); $current_post[‘post_status’] = ‘publish’; wp_update_post($current_post); } } if (isset($_GET[‘queue’])) { if ($_GET[‘queue’] == “true”) { $current_post = get_post( $_GET[‘post_id’], ‘ARRAY_A’ ); $current_post[‘post_status’] … Read more

How to define which register_post_status goes to which register_post_type?

They don’t do this. Custom post statuses are basically a trap. They seem like they might make sense, but likely they won’t do what you think they will do and cause ton of grief with edge cases on top. You should consider custom taxonomies for your CPT–specific data. They are much more robust and safe … Read more