16

A faster solution is: $post = array( 'ID' => $post_id, 'post_status' => $status ); wp_update_post($post); This way you don't have to get the post.


14

See this Codex page. In general the hook is {old_status}_to_{new_status}. (Untested) but in your case, the hook would be pending_to_draft: add_action('pending_to_draft','wpse45803_pending_to_draft'); function wpse45803_pending_to_draft($post){ //Do something } You might want to look up the wp_transition_post_status function. You could also use the ...


13

here you go: <?php /* Plugin Name: ajaxed-status Plugin URI: http://en.bainternet.info Description: answer to : Custom column for changing post status via ajax http://wordpress.stackexchange.com/questions/33442/custom-column-for-changing-post-status-via-ajax Version: 1.0 Author: Bainternet Author URI: http://en.bainternet.info */ if ( !class_exists('...


12

register_post_status is used for creating a custom post status. The protected argument, if true, specifies that a user must be logged in and have edit permissions on the post to view (preview) it. For example, you said that the "draft" post status has protected set to true. This means that you can only view (preview) the draft post if you have permission ...


9

You can create your own meta box with a checkbox and only select posts that where checked: Add metabox code /* Define the custom box */ add_action( 'add_meta_boxes', 'my_slider_add_custom_box' ); /* Do something with the data entered */ add_action( 'save_post', 'my_slider_save_postdata' ); /* Adds a box to the main column on the Post and Page edit ...


9

There is a great Step by Step description on how to do that here http://jamescollings.co.uk/blog/wordpress-create-custom-post-status/ To add your custom post status to the drop-down menue, just add the following to your themes function script: add_action('admin_footer-post.php', 'jc_append_post_status_list'); function jc_append_post_status_list(){ global $...


8

You can use 'publish' === get_post_status( $id ), where $id could be the current page ID retrieved via get_the_ID() or any other.


8

This solves my problem: register_post_status('my_custom_post_status', array( 'label' => __('The Label', 'domain'), 'public' => !is_admin(), 'exclude_from_search' => true, 'show_in_admin_all_list' => false, 'label_count' => //blablabla )); !is_admin() makes the status only public on the frontpage. If you find a better ...


8

I guess it should work . As long as $id is available things are easy. <?php if (empty($items)) { $ret .= " 'No new videos.'"; $postid = $post->ID; //Supply post-Id here $post->ID. wp_update_post(array( 'ID' => $postid, 'post_status' => 'draft' )); } else foreach ( $items as $item ) : ?> Give it a ...


8

You need to set the who parameter in get_users <?php $blogusers = get_users( 'orderby=post_count&who=authors' ); foreach ( $blogusers as $user ) { echo '<li>' . esc_html( $user->display_name ) . '</li>'; } ?> EDIT Seems I was to fast answering. The code in your question and in my answer is the start to what you ...


7

Keep things simple - leave your archive templates alone and place this in your functions.php; add_action( 'pre_get_posts', function ( $wp_query ) { global $wp_post_statuses; if ( ! empty( $wp_post_statuses['future'] ) && ! is_admin() && $wp_query->is_main_query() && ( $wp_query->...


7

There is simple way, how to get all posts with any status: $articles = get_posts( array( 'numberposts' => -1, 'post_status' => 'any', 'post_type' => get_post_types('', 'names'), ) ); Now you can iterate throughout all posts: foreach ($articles as $article) { echo $article->ID . PHP_EOL; //... }


7

Your code should be sound, and should add the desired status to the $wp_post_statuses global array. If you are expecting it to show up in the admin drop-down, however, this is an ongoing issue: https://core.trac.wordpress.org/ticket/12706


6

The WP_Query class method ->query() accepts an any argument for post_status. See wp_get_associated_nav_menu_items() for a proof. The same goes for get_posts() (which is just a wrapper for above call).


6

There is no default way in WordPress to do this task, as Pieter Goosen pointed out, exists the argument who for get_users() that returns users that can post, not the users that have posted. However, you can use 'pre_user_query' to add a JOIN SQL clause to only get users that have at least one post. To be honest, when you query users ordering them by post ...


6

To check post with post status private, you could run the following: if (get_post_status() == 'private' && is_user_logged_in()) { // it's private and user is logged in, do stuff } elseif (get_post_status() == 'draft') { // it's draft, do stuff } else { // it's something else, do stuff } Or, in your current setup, you can simply only ...


5

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') );


5

You might want to remove those counts and replace them with your own. function insert_post_counts($views){ //Run your query to count posts //use wp_cache_set and wp_cache_get to optimize performance $edit_url = admin_url( 'edit.php' ); $views['all'] = 'All <a href="'.$edit_url.'">('.$all_count.')</a>'; $views['publish'] = '...


5

You can create your custom button in a function and hook it into post_submitbox_misc_actions and this will add it right above the publish button. To change the status use wp_update_post in an Ajax function. Give it a try and post back with your code if you run into any problems. UPDATE: add_action('post_submitbox_misc_actions', '...


5

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']...


5

Preface Once post preview is frontend, the comment form depends on how theme handle it. I will assume in this answer that the comment form is shown using the standard comment_form() function. The previous assumption isn't enough, in fact comment_form is probably the function in WordPress core with more hooks. There is almost an hook for every line. So what ...


5

The arguments you are using are wrong. They should be: $args = array( 'numberposts' => '10', 'post_type' => 'post', 'post_status' =>'publish', 'tax_query' => array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array( 10, 11, 57 ),...


5

This largely depends on where within the boot/request sequence you decide to make an attempt at retrieving statuses and it also depends on whether someone, thing, plugin or theme is doing something, funky, or not but the latter is less likely the case. Useful API functions: get_post_statuses docs | source Retrieves statuses for the built in post type of ...


4

In that case your error lays with wp-ecommerce itself as you've ruled out any via process of elimination. The last thing I would suggest you do, is switch from your current theme to the default WordPress theme (still ensuring that all plugins except wp-ecommerce are disabled) and if the problem still persists then its definitely wp-ecommerce. We can ...


4

You probably have some custom functions in your themes functions.php Add a return; on top of this file. If the problem is solved: Move it below the first function. Proceed this way until you've found the function that is causing the problem. If this doesn't work: Go and do the same for one template file after each other until you found the file that is ...


4

WP_Query has a bug (#29167) when you try to fetch posts with (almost?) any other status than publish. This bug seems to be fixed in trunk. I haven’t tested it, so I cannot tell if it covers your use case. Try it, and give feedback there if it doesn’t. There are two workarounds: Use get_post( $post_id ). This runs its own query and isn’t affected by this ...


3

Every time you edit a post/page, WordPress creates timely revisions of it. Check the Firebug console for the requests that are sent at regular intervals when you are on the edit page. They are useful if you lose the post content at some point and want to get back to an earlier version of the post. Once you publish the final version of the post then you can ...


3

That's because the fields weren't set then. Note: The »Autosave« process/request also doesn't save them. Use the values from $_POST instead for your "new_to_publish" action.


3

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 so that it respects the 'promoted' status as ...


3

You get the full post object as a second parameter on save_post. Use it to change the status just like the following code. add_action( 'save_post', 'wpse_78351_status', 10, 2 ); function wpse_78351_status( $post_ID, $post ) { remove_filter( current_filter(), __FUNCTION__ ); if ( 'trash' !== $post->post_status ) //adjust the condition { ...


Only top voted, non community-wiki answers of a minimum length are eligible