Allow a subscriber to be an author and view only his post

You must write a small plugin for the Hook pre_get_posts; an example: add_action( ‘pre_get_posts’, ‘fb_allow_draft’ ); function fb_allow_draft( $query_obj ) { // only on admin screen use this filter if( ! is_admin() ) return; // change our query object to include any post status $query_obj->query_vars[‘post_status’] = ‘any’; } If you will specific this new loop … Read more

Showing posts for today and future

Use get_posts function with WP_Query params instead of get_children. The code will than look like this: $today = getdate(); $pages = get_posts( array( ‘post_status’ => array( ‘publish’, ‘future’ ), ‘post_type’ => ‘event’, ‘sort_order’ => ‘ASC’, ‘orderby’ => ‘date’, ‘year’ => $today[“year”], ‘monthnum’ => $today[“mon”], ‘day’ => $today[“mday”] ) ); foreach ( $pages as $post ) … Read more

Display amount of pending posts in back/front end

Easy native SQL query: global $wpdb; $sql = <<<SQL SELECT post_status, COUNT( * ) AS count FROM {$wpdb->posts} WHERE post_status=”pending” SQL; $result = $wpdb->get_results( $sql ); The result will be something like + ———– + —– + | post_status | count | + ———– + —– + | pending | 158 | + ———– + … Read more

How to add custom status to quick edit

Unfortunately there are no filters or actions for modifying the post status select in quick edit (WP_Posts_List_Table::inline_edit()) – you’d need to resort to JavaScript: (function($){ $( “select[name=_status]” ).each( function () { var value = $( this ).val(); if ( value === “pending” ) $( “option[value=pending]”, this ).after( “<option value=”status-1″>Status 1</option>” ); else if ( value … Read more

Taxonomy vs Post Status

Probably post_status but this answer is probably irrelevant in your case. You have your own application with its own usage pattern of the DB therefor the assumptions used when designing wordpress DB for use by core might not fit you. Maybe you will need to add another index to the posts table, maybe create optimized … Read more

Post Status Frontend Announcement

You can create an easy to use function to do that for you. Like so: <?php function sg_user_posts_by_type($userid, $post_status) { $args = array( ‘numberposts’ => -1, ‘post_status’ => array($post_status), ‘author’ => $userid ); $count_posts = count(get_posts($args)); return $count_posts; } if (is_user_logged_in()) { // GET CURRENT USER DATA $user_id = get_current_user_id(); $user_data = get_userdata($user_id); $publish_count = … Read more

WP_Query will not display draft posts

You can just ‘post_status’ => ‘any’. Here is the completed code. global $wp_query; $ids = array(130,132); $args = array( ‘post_status’ => ‘any’, // ‘post_status’ => ‘any’, // same output ‘post__in’ => $ids, ‘post_type’ => ‘alpha’ ); $q = new WP_Query($args); foreach ($q->posts as $post) { echo $post->id; } Official docs on post_status option https://developer.wordpress.org/reference/classes/wp_query/#status-parameters

What function publishes a post when you click the publish button?

Normally, posts are published by the wp_insert_post() function. Essentially, the post_status is changed from draft to publish. Nothing more to it than that, really. There is also the wp_publish_post() function, which is really only used for scheduled posts. It does the basic job of transitioning a post from “future” to “publish”, and also calls the … Read more

Submitted for Review back to a Draft page

This is not a permissions issue – contributors can (by default) change a post from pending to draft. To test, submit a post for review, then “quick edit” it – you’ll see that you’re able to change the status back to draft. The issue is that the “save as draft” button in the UI is … Read more

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