Custom CPT Status | Draft, Publish, Trash, +1

This topic contains 3 replies, has 3 voices, and was last updated by  Alex Rollin 5 years, 7 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: , ,

  • Author
    Posts
  • #442600

    Rich Harris
    Expired Member
    Post count: 37

    Hi.
    I’m looking to add a custom post status, but I want to add it to Listings. For example, posts can be published, draft or trash. I’d like the option to add archive. Ideally, I could set the Expiry Process to set expired posts with the new status.

    Here is a bit of code that adds this functionality for native WP posts:

    
    
    <?php
    function jc_custom_post_status(){
         register_post_status( 'archive', array(
              'label'                     => _x( 'Archive', 'post' ),
              'public'                    => true,
              'show_in_admin_all_list'    => false,
              'show_in_admin_status_list' => true,
              'label_count'               => _n_noop( 'Archive <span class="count">(%s)</span>', 'Archive <span class="count">(%s)</span>' )
         ) );
    }
    add_action( 'init', 'jc_custom_post_status' );
    
    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 == 'post'){
              if($post->post_status == 'archive'){
                   $complete = ' selected="selected"';
                   $label = '<span id="post-status-display"> Archived</span>';
              }
              echo '
              <script>
              jQuery(document).ready(function($){
                   $("select#post_status").append("<option value="archive" '.$complete.'>Archive</option>");
                   $(".misc-pub-section label").append("'.$label.'");
              });
              </script>
              ';
         }
    }
    ?>

    Adding the above to the theme’s function.php is supposed to add archives to my post statuses (not sure I did it right, so be wary of using that code).

    Can you tell me how I’d change that code to effect ‘gd_places’ instead of ‘posts’, or any other variations that would work on CPTs? Or point me in a better direction to create an archive for expired GD CPTs.

    #442627

    Kiran
    Moderator
    Post count: 7069

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #444517

    Rich Harris
    Expired Member
    Post count: 37

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #444609

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket