Articles of post status

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

I know I can do wp_untrash_post( $post_id ); And check the post status with $post_status = get_post_status ( $post_id ) I’m in a situation where I must untrash some posts but only if the post itself was not a simple draft Is it possibile to check something like a previous state of a trashed post?

How to change post status in hook?

I have similar problem as described in How to trap "Publish" button to check for meta box validation? Answer there is to hook into save_post and change post type. How can I do it? I try to use wp_transition_post_status but it doesn’t work for me… function myHook( $post_ID, $post ) { wp_transition_post_status(‘pending’, $post->post_status, $post ); […]

Show recent published posts

I want to list recent published posts of my wp blog and exclude certain posts of some categories. The following code works fine, 10 recent posts are listed and posts in the listed categories are ignored. However, draft posts are listed as well. $args = array( ‘numberposts’ => ’10’, ‘tax_query’ => array( ‘post_type’ => ‘post’, […]

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

I’m using this function from this accepted answer, which gets all values for a custom field key (cross-post). How could it be modified to allow an array of post statuses? function get_meta_values( $key = ”, $type = ‘post’, $status = ‘publish’ ) { global $wpdb; if( empty( $key ) ) return; $r = $wpdb->get_col( $wpdb->prepare( […]

Show scheduled posts in archive page

I’d like my archive.php page’s daily view (is_day) to display scheduled posts (post_status=future). For example, if I go to mysite.com/2011/05/20 I would see all posts scheduled to appear on May 20. The archive page’s loop starts with: if ( have_posts() ) the_post(); and ends with: rewind_posts(); get_template_part( ‘loop’, ‘archive’ ); Do I need to make […]

Individual post. Meta_key, taxonomy or post status for separation?

I have a posts with custom type – TOUR. Among ordinary Tours sometimes I need to create “personal” or “private” Tour, which will be shown only to assigned user. What the way is better to exclude this “private” Tour from others and not show it in the Tours list. Threre are meta_value, taxonomy or post_status […]

Create front end link to save post (or unpublish post) as draft

I have created a front-end posting and dashboard system for my users to add and edit their own posts. In the dashboard area, I have a list of their posts and the following options for each post: View | Edit | Publish/Un-Publish | Delete I have all of these links working except for the “un-publish” […]

Problem duplicated shortlinks bitly

I’ve this plugin to create shortlink using the bitly API, but there’s a problem! function yoast_bitly_shortlink($url, $id, $context, $allow_slugs) { if ( ( is_singular() && !is_preview() ) || $context == ‘post’ ) { $short = get_post_meta($id, ‘_yoast_bitlylink’, true); if ( !$short || $short == ” ) { if ( !defined(‘BITLY_USERNAME’) || !defined(‘BITLY_APIKEY’) ) { $short […]

How can a guest view the “Pending Review” Post?

When a user creates a new post it will have “pending” status. So I want the visitor (guest – not logged user) to be able to view “Pending” posts and vote it to “Publish” if enough “X Votes”. Google bot can also crawl “Pending” Posts. I want to use permalink for “Pending” Post. How can […]

Custom Post Status not showing in Custom Post Type ALL view

I’ve created a simple plugin for our WP site to allow us to enter in our products that we despatch. To do this I’ve created a new Post Type called ‘order_packing’ and within that 2 new Post Statuses: ‘In Packing’, ‘Sent’. The problem I have is that list correctly shows the packing lists within the […]