Tag Info

Hot answers tagged

10

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


10

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


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


7

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


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

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

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


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

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

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

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

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

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

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


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

You can alter a post status after init by changing the global variable $wp_post_statusses: function alt_post_status() { global $wp_post_statuses; $wp_post_statuses['custom_status']->public = true; } add_action( 'init', 'alt_post_status' ); register_post_status() (line 922) does the same thing: ... global $wp_post_statuses; if ...


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

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

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

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


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

Assuming you want to delete by date, here is a basic concept. You'd need to figure out when you want this to run, otherwise, as I commented above, you'll end up with only 1 post if it runs repeatedly. Edit: Including parameter for a bit of safety <?php function doomsday_device($herd_thinning) { if(empty($herd_thinning)) { return; } ...


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


1

Probably post_status but this answer is probably irrelevant in your case. You have your own application with its own usage pattern of the DB therefor the assumptions used when designing wordpress DB for use by core might not fit you. Maybe you will need to add another index to the posts table, maybe create optimized table of your own. Caching is also an ...


1

I think the best solution, as discussed in chat, is point 3, programmatically adding a draft (or custom post status) via the use of wp_insert_post where amongst other parameters you can set the likes of; 'post_date' => [ Y-m-d H:i:s ] //The time post was made. 'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT. ...without ...


1

I'm then trying to figure out how to change the post status once their subscription is up function downgrade_user_role( $entry, $subscription_id, $transaction_id, $new_payment_amount ) { $user = GFUserData::get_user_by_entry_id( $entry['id'] ); $user->set_role( 'subscriber' ); global $wpdb; $wpdb->query( $wpdb->prepare( ...


1

Easy native SQL query: global $wpdb; $sql = <<<SQL SELECT post_status, COUNT( * ) AS count FROM {$wpdb->posts} WHERE post_status = 'pending' SQL; $result = $wpdb->get_results( $sql ); The result will be something like + ----------- + ----- + | post_status | count | + ----------- + ----- + | pending | 158 | + ----------- + ----- ...



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