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,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Aggregated <span class="count">(%s)</span>', 'Aggregated <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', 'custom_post_status' );
Thanks for help with this.
There is a great Step by Step description on how to do that here https://www.jclabs.co.uk/create-custom-post-status-in-wordpress-using-register_post_status/
To add your custom post status to the drop-down menue, just add the following to your themes function script:
With this you have your custom post status up and running in 5 min, saved me a bunch of time!
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
Register a post status “aggregated” for custom post type “recipes” :
In the “recipes” custom post edit screen’s publish metabox, adding the custom post status in the dropdown and change the “Save Draft” button label if the selected post status is “aggregated” :
Add the custom post status in the quick edit screen of the custom post admin grid :
Display the custom post status total in the custom post admin grid :
Here is the working code for WP 6.2 without using JQuery
// 1. Register a post status “aggregated”
// 2. In the post edit screen: adding the custom post status in the dropdown
// 3. In the quick edit screen (list page): adding the custom post status in the dropdown