Tag Info

Hot answers tagged

9

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


8

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


7

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


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


5

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


4

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 = get_bloginfo('wpurl').'/wp-admin/edit.php'; $views['all'] = 'All <a href="'.$edit_url.'">('.$all_count.')</a>'; ...


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

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


3

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


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

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


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


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

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


1

Is it possible that you have accidentally changed your user role from Editor to Contributor -- perhaps in your functions.php file (which is why it might only happen on your custom theme)? Contributors roles can only save draft for new posts and can't publish. You might like to check that your didn't change anything in your custom theme so that if user ...


1

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 solution please post ...


1

I'm pretty sure only attachments have post status "enforcement" ("inherit" or "private"), and that's only inside wp_insert_attachment(). Otherwise there's no cron action or routine I'm aware of that'll change stati. I still think you should opt for registering it though. Without any arguments, everything will still behave the way it does currently; they ...


1

WordPress has this functionality: by setting the publication date to the future in the WordPress 'publish' box, the post will be given 'future' status and will be scheduled to publish for that date. My guess is that the problem arises because you haven't set the GMT time - which is what the WordPress uses to schedule the publications. Or otherwise you've ...


1

Use Sticky Posts. In the Post editor find the "Publish" section. Next to "Visibility" click on edit and then check the "Stick this post to the front page" option there. Click save and you're done. In the loop, you can check if a post is_sticky(). To loop them, you can use the post__in or post_not__in keys for your query with a value of get_option( ...


1

How about the Revisionary plugin? It allows you to set pages as "save as pending" after making changes to an existing published page, so that your changes are saved as a draft but not yet pushed live. You can also use it to help customize user roles - so if you want to allow someone to be able to edit content, but not let them hit the publish button without ...


1

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


1

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


1

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'; } ...


1

I believe get_posts returns all published (no-private posts) but does display password protected posts. In fact, by default, the standard WP_Query loop does this as well. So by default, private posts shouldn't appear. If you wanted to display private posts for those logged in, and not those who are logged out, you could use the permissions parameter ...


1

What you could do is create a metabox for the 'People' custom post type which would have radio values 'Not Sponsored' and 'Sponsored' (Not Sponsored b default). PayPal posts some transaction details to the notify url you have specified. Once you recieve the proper information from PayPal, like payment status is completed, then you could update the particular ...


1

You could use get_post_status(): function is_trash( $post_id = 0 ) { 0 == $post_id and $post_id = get_the_ID(); return 'trash' === get_post_status( $post_id ); } Side note: To get a list of all registered post status objects use get_post_stati() – yes, that's wrong.


1

You could add a hidden input into the page to pre-set the title field, because it won't be on the page(because the type doesn't support titles). Slug is produced from the title, so you should only need add a title value. Something like this should work(though untested).. add_action( 'submitpost_box', 'hidden_type_title' ); function hidden_type_title() { ...


1

There isn't much native functionality in WP to apply admin powers on front end. Front-end Editor plugin is usually great for such, but changing post status is one feature it seems to lack (maybe it's worth suggesting to scribu). So you are basically stuck with writing this from scratch - implementing JS on front end to make Ajax request and backend handler ...



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