How to integrate blog status?

You can use the option API to set the blog_status and then display it. If you want to use blog description for the purpose you already have the UI available to set it from Setting->General and set the tag line to update your blog status. Then you can display the tag line anywhere in your … Read more

How to untrash a post only if it was not a draft?

Just as @cybmeta mentioned, the info is stored in the post meta table. When we trash a post then the post meta key _wp_trash_meta_status is added with the value of the previous post status (publish, pending, draft, … ). Within the wp_trash_post() function, we have: add_post_meta($post_id,’_wp_trash_meta_status’, $post[‘post_status’]); add_post_meta($post_id,’_wp_trash_meta_time’, time()); We might therefore try: // Get … Read more

wp_transition_post_status does not change the status of the post

This function contains do_action() calls for post status transition action hooks. The order of the words in the function name might be confusing – it does not change the status of posts, it only calls actions that can be hooked into by plugin developers. https://codex.wordpress.org/Function_Reference/wp_transition_post_status What you want is wp_update_post, you’re also using WP_Query incorrectly: … Read more

Which is the better way to get the status of a post?

None of them. A, C and D all indicate that you’re inside a loop, and want the status for the current post. But if that’s the case then the first line on all of them is redundant. This is all you’d need if you want the status of the ‘current post’: $current_post_status = get_post_status(); get_post_status() … Read more

How to Modify this $wpdb query to accept an array of post statuses

Use the IN operator for arrays. When using $wpdb->prepare() you don’t have to use quotes around the string placeholder %s. The string placeholder will be quoted automatically. That’s also the reason why you have to take precautions when using $wpdb->prepare() with the IN operator if the array values are strings. This first example doesn’t use … Read more

Can’t get drafts with WP_Query using post_status parameter

Try passing it as an array. For example $args = array( ‘p’ => 1234, ‘post_type’ => ‘any’, ‘post_status’ => array(‘draft’) ); Or for all types $args = array( ‘p’ => 1234, ‘post_type’ => ‘any’, ‘post_status’ => array(‘publish’, ‘pending’, ‘draft’, ‘auto-draft’, ‘future’, ‘private’, ‘inherit’, ‘trash’) );

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