Tag Info

Hot answers tagged

12

You can use the post_status parameter: * 'publish' - a published post or page * 'pending' - post is pending review * 'draft' - a post in draft status * 'auto-draft' - a newly created post, with no content * 'future' - a post to publish in the future * 'private' - not visible to users who are not logged in * 'inherit' - a revision. see get_children. * ...


11

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


9

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 ( ...


8

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


7

I found this plugin called EditFlow that says it allows you to add custom statuses. Apparently it's designed for use in a newsroom. (FYI, I searched the WordPress plugins directory for "custom post status.")


7

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


6

Keep things simple - leave your archive templates alone and place this in your functions.php; if ( !is_admin() ) : function __include_future( $query ) { if ( $query->is_date() || $query->is_single() ) $GLOBALS[ 'wp_post_statuses' ][ 'future' ]->public = true; } add_filter( 'pre_get_posts', '__include_future' ); endif; Essentially, it ...


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

Here is a function that changes post status /* $post_id - The ID of the post you'd like to change. $status - The post status publish|pending|draft|private|static|object|attachment|inherit|future|trash. */ function change_post_status($post_id,$status){ $current_post = get_post( $post_id, 'ARRAY_A' ); $current_post['post_status'] = $status; ...


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


4

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


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


3

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


3

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


3

I would filter pre_get_posts. function allow_pending_posts_wpse_103938($qry) { if (!is_admin() && current_user_can('edit_posts')) { $qry->set('post_status', array('publish','pending')); } } add_action('pre_get_posts','allow_pending_posts_wpse_103938'); That should show pending posts to your editors for all of your queries on the front ...


3

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


3

I wonder if you could use something as simple as this: (similar to the suggestion of @ialocin) /** * Use the "Force" on the post status ;-) */ add_action( 'wp_insert_post_data', function( $data, $postarr ){ $change_post_status = array( 'draft', 'private' ); // Edit to your needs if( 'cpt' === $data['post_type'] && in_array( ...


3

Sorry guys, I found my answer: add_action('wp','redirect_stuffs', 0); function redirect_stuffs(){ global $wpdb; if ($wpdb->last_result[0]->post_status == "private" && !is_admin() ): wp_redirect( home_url(), 301 ); exit(); endif; } Posts/Pages are removed from the sitemaps, but the page still shows up on the site so ...


3

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


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


2

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).


2

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


2

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.


2

I think I find the answer-- wp-include/post.php: if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) ) $post_status = 'inherit'; So, whatever status will be saved as "inherit".


2

As probably there is not so many unpublished posts with images, You could exclude them from Your WP_Query, adding: 'post_parent' => '-12,-34,-56' this would add overhead of only one query grabbing id's of these posts


2

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


2

Firstly, I would have to agree with @fencepost's answer. However, I couldn't resist posting a solution, so here we are! function __intercept_private_page( $posts, &$wp_query ) { // remove filter now, so that on subsequent post querying we don't get involved! remove_filter( 'the_posts', '__intercept_private_page', 5, 2 ); if ( !( ...


2

After WP 2.3 you have for all status an hook: {$new_status}_{$post->post_type} Alternative you can use ans if for the status on hook save_post; an example for post_type post, you can change this 'post' to your post_type or defaults form WP: public function set_status_private($id, $post) { if ( is_object($post) && ...


2

There is indeed processing in WP_Query which might prevent posts from displaying if they are not simply public. Since there are several conditions there it is a little hard to guess why it fails in your specific case. It might be issue with how permissions are setup or some edge case (which querying for non-public posts is full of).



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