Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
I think the code is right. Maybe you have this source in a other function to call this. When run the add_action()? –  bueltge Mar 4 '13 at 19:36
    
Could you please explain your answer in more details? thanks! –  dclawson Mar 4 '13 at 22:03
    
Is the add_action( 'init' inside a class or function, there you call about a other hook. It is possible, that you start this to lat and the hook init can nor fired. –  bueltge Mar 5 '13 at 14:13
    
How did you resolve this issue? I have exactly the same problem now. I like to add the new custom status to the drop down list of the custom-post admin area, that allows the user to select (Pendig Reveiw, Draft, NEW_CUSTOM_STATUS) from the list of Stati... –  Greeso Aug 24 '13 at 9:19
add comment

2 Answers

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

share|improve this answer
add comment

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 $post;
 $complete = '';
 $label = '';
 if($post->post_type == 'recipes'){
      if($post->post_status == 'aggregated'){
           $complete = ' selected=\"selected\"';
           $label = '<span id=\"post-status-display\"> Aggregated</span>';
      }
      echo '
      <script>
      jQuery(document).ready(function($){
           $("select#post_status").append("<option value=\"aggregated\" '.$complete.'>Aggregated</option>");
           $(".misc-pub-section label").append("'.$label.'");
      });
      </script>
      ';
  }
}

With this you have your custom post status up and running in 5 min, saved me a bunch of time!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.