Is there a way I can call a link so when clicked it publishes the post via the ID I provide? I have get_delete_post_link( $postID ) set fine, and would like to do the same to make a draft go to published, or if you can't publish post, make it pending. I also have this code running in my functions.php file so may be also a way to call this if a link is clicked.
I have a custom post status called 'dead.' I am trying to create a wp_query to show all posts for a custom taxonomy. If I specify 'any' for the post_status I do get published posts and my 'dead' post_status posts. Likewise, if I set the post_status parameter to only 'dead' I do get just those posts. But, if I try to set the post_status to show both published and dead post_status posts via an array I can only get the …
I'm creating a website where user pays to publish posts. If this user membership expires, the role changes from "Subscriber" to "Pending". I need a code that allows to update all posts to draft if certain user's role is "Pending" and then back to publish if is "Subscriber". Any suggestions on this problem? I only found this plugin but it's not working.
I'm trying to get WP_Query to display ALL posts in an array but only ones with status published are showing: global $wp_query; $ids = array(130, 132); $args = array( 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'), // 'post_status' => 'any', // same output 'post__in' => $ids, 'post_type' => 'alpha' ); $q = new WP_Query($args); foreach ($q->posts as $post) { echo $post->id; } However this displays post id's regardless of their status: // post status foreach ($ids as $id) …
I used this code to make a custom post status which is public so that the post is still available for people to view. // Define new awaiting status function my_custom_post_status(){ register_post_status( 'awaiting', array( 'label' => _x( 'Changes Awaiting Approval', 'custom-post-type' ), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Changes Awaiting Approval <span class="count">(%s)</span>', 'Changes Awaiting Approval <span class="count">(%s)</span>' ), ) ); } add_action( 'init', 'my_custom_post_status' ); Then I added this code …
I want to hide or remove a custom post status when it is set to a specific one. e.g. If I have a post set to status "pendingreviewf" I want to hide the option to change it to the status "shipedf" and "pricenotaxf". I am using the PublishPress plugin to create the custom status. The code so far: function adminstage1() { if ( ! function_exists( 'PublishPress' ) ) return; if ( ! PublishPress()->custom_status->is_whitelisted_page() ) return; $hide_post_status = array( 'pendingreviewf' ); …
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 ALL (2) total - but doesn't list the packing lists. If I click the 'Sent' status then I get both shown in the list. So …
I have a Custom post type in wordpress in which when creating a new post 3 child subposts are created automatically. For example, I create the post and assign it some status 'Publish', 'pending', 'draft' or another: Post Company 1 -Subpost 1 (it is created automatically) -Subpost 2 (it is created automatically) -Subpost 3 (it is created automatically) Removing the parent (moves to 'trash' ) will also remove the subposts. But when you restore them, they should be in the …
How do I create a custom post status and display it above the table of my custom post type? Example: All(9) | Published (7) | Custom_Status(2) I used the advance custom fields plugin to create a dropdown which represents the status of the post. But I'm sure that that does not represent the actual status of the post since it won't be saved in the post_status column in the database. Feel free to suggest plugins. I tried the edit flow …
I searched for an answer but couldn't find any. How can I allow bulk edit orders to wc-processing status? Currently I can any other status but this one and it's making the work harder, making me go in each order and change one by one. Thanks.
I'd like to return a 410 code for posts (of custom type "news") which have previously been published (and therefore have a url indexed by search engines), but have now had the post status set to draft. Here's my attempt: function news_gone() { global $post; if ( is_singular( 'news' ) && get_post_status($post->id) == "draft" ) { global $wp_query; $wp_query->set_404(); status_header(410); } } add_action( 'template_redirect', 'news_gone' ); This, however, has no effect - is template_redirect the correct hook, or is there …
The blog page should show scheduled posts in the main loop. I've done that with this code: /** * Show scheduled posts in main loop */ function fa_show_scheduled_posts( $query ) { if( $query->is_main_query() && ! is_admin() && $query->is_home() ) { $query->set( 'post_status', [ 'publish', 'future' ] ); } } add_action( 'pre_get_posts', 'fa_show_scheduled_posts' ); But there's a different section that shows the 4 latest posts with a WP_Query. Even if I change the post status to only be published posts, it …
I have a custom post type recipes. I am using a cron script to automatically aggregate news into the database. It is currently being imported and saved as 'Pending Review'. Is it possible to create another post status called Aggregated which will list all of the aggregated news to be published? I tried using the register_post_status function, however this didn't seem to work: function custom_post_status(){ register_post_status( 'aggregated', array( 'label' => _x( 'Aggregated', 'recipes' ), 'public' => false, 'exclude_from_search' => true, …
I have created 2 custom post types (using CPT UI). Parent and children. Many children can be associated to one parent using a post object field(add_to_parent). I would like the parent post type to be automatically set to private if there are no post objects (children) linked to it, and then once a child is associated to the parent, the parent then becomes published. Any ideas would be greatfully received.
I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in all states, mainly published, trashed and the pending. I am now using a simple query but it is returning only the published posts. $query = array( 'post_type' => 'my-post-type', 'post_author' => $current_user->ID ); query_posts($query); Can anyone help? What else do I need to do?
I have added a custom post status of rejected, working just fine. I want to add the post status to the body of the post when it is being previewed. In order to style a front end information box seen by the admin.
I have written a function to loop through the users posts, and im trying to display each of the posts by their status, with a different message for each status group. for some reason - get_post_status doesnt work, nor do any of the other hooks. can anyone help? ive even tried to temporarily shorten the function and just echo out the variables to see what theyre doing and its just blank. function user_item($type, $tax, $term_name, $term_id) { if (!is_user_logged_in()) return; …
By default Wordpress assigns the draft status to a post that has been untrashed. I would like to assign the pending status to posts that are untrashed. This seems to be possible with wp_untrash_post_status, but I can't seem to find the proper way to use it. I have this in my code : add_action( 'untrash_post', 'my_function' ); function my_function( $post_id ) { apply_filters( 'wp_untrash_post_status', 'pending', $post_id, 'pending' ); } What am I doing wrong ?
I need to display the online status (online/offline) for each author page (custom author page template). is_user_logged_in() only applies to the current user and I can't find a relevant approach targeting the current author e.g. is_author_logged_in() Any ideas? Answer One Trick Pony was kind enough to prepare the coding for two to three functions using transients, something I hadn't use before. http://codex.wordpress.org/Transients_API Add this to functions.php: add_action('wp', 'update_online_users_status'); function update_online_users_status(){ if(is_user_logged_in()){ // get the online users list if(($logged_in_users = get_transient('users_online')) …
I am trying to set a Post's default visibility to 'Private' when a user first creates the post. They should then have the ability to manually select 'published' from the sidebar dropdown once they are ready or the post has been reviewed. My goal is to ensure posts aren't accidentally published if the user isn't ready or forgot to select 'private'. I can't find any code that works for Gutenberg. Most I researched are outdated and for the classic editor. …