Include Drafts or Future posts with count_user_posts?

This will do what you want: $args = array( ‘author’ => $curauth->ID, ‘post_status’ => array( ‘publish’, ‘pending’, ‘draft’, ‘future’ ) ); $posts = new WP_Query(); $post_count = $posts->found_posts; It will include drafts, pending posts, published posts, and future posts. There are more you can set, such as trashed posts, and private posts, but that didn’t … Read more

Getting the different post statuses + count like in edit.php, in a custom submenu page

The class used in edit.php is an extension of the WP_List_Table: WP_Posts_List_Table. See wp-admin/includes/class-wp-posts-list-table.php. And here you find a call to wp_count_posts( $type=”post”, $perm = ” ). The first parameter is for the post type, the second can be empty or readable. If it is readable and the current user has no permission to see … Read more

Change scheduled posts to published

Ok… so when trying to turn a future post to a published post you need to remember to set “post_date_gmt” and not only the “post_date” to the desired date. Thanks to @gmazzap which helped me get there… here is a working example based on my question /* CHANGE PENDING POSTS TO PUBLISHED POSTS */ function … Read more

Check whether a custom taxonomy term has published posts?

function get_issues() { $output = array(); $hlterms = get_terms(‘issue’, array(‘orderby’ => ‘id’, ‘order’ => ‘DESC’,’hide_empty’ => false)); foreach($hlterms as $term){ array_push($output, $term->term_id); } return $output; } This would return you term id as per the recent and then in your second function start iterating to get the posts for latest issue. function get_posts_for_current_issue() { $total_issues … Read more

Custom Post Status Posts viewable to the public

I have been looking to do something like that with EditFlow, where a custom status will determine if the post shows up on the homepage via a get_posts() query. $promoted_posts = get_posts( array( ‘post_status’ => ‘promoted’ ) ); That works, but it looks like I’ll need to filter the WP Query on the single page … Read more

How to set default status to custom post type

Hook wp_insert_post_data filter to force a post status to be set as incomplete before it can be set as published. With the following code only a post that is set as incomplete can be saved: add_filter( ‘wp_insert_post_data’, ‘prevent_post_change’, 20, 2 ); function prevent_post_change( $data, $postarr ) { if ( ! isset($postarr[‘ID’]) || ! $postarr[‘ID’] ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)