Custom Post Status Display
-
Hello all,
I have a problem with my custom post status since I have updated WordPress to version 4.7.
I’ve added some custom post status in my functions.php. This worked fine up to version 4.6.1. But now when I open a post (edit.php), the custom post status isn’t displayed. There is just a “Status: Edit;” If I edit the status or save the post, it is displayed correctly (Status: Archive Edit).
I compared the html code via inspect element – the
label
is gone:
WP 4.6.1:<div id="misc-publishing-actions"> <div class="misc-pub-section misc-pub-post-status"> <label for="post_status"> ::before Status: <span id="post-status-display">Testcloud</span> </label> <span id="post-status-display"></span> <a class="edit-post-status hide-if-no-js" href="#post_status"></a> <div id="post-status-select" class="hide-if-js"></div> </div>
WP 4.7:
<div id="misc-publishing-actions"> <div class="misc-pub-section misc-pub-post-status"> ::before Status: <span id="post-status-display">Testcloud</span> <span id="post-status-display"></span> <a class="edit-post-status hide-if-no-js" href="#post_status" role="button"></a> <div id="post-status-select" class="hide-if-js"></div> </div>
An example of my functions.php for adding a custom post status is:
Register status:function register_custom_post_status() { register_post_status('archive', array( 'label' => _x('Archive', 'page'), 'public' => true, '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', 'register_custom_post_status');
Add status to dropdown list in edit.php:
function custom_post_status_submitbox_misc_actions($states) { global $post; if($post->post_type == 'page') { if($post->post_status == 'archive') { echo '<script> jQuery(document).ready(function($) { $("select#post_status").append("<option value=\"archive\" selected=\"selected\"> Archive </option>"); $(".misc-pub-section label").append("<span id=\"post-status-display\"> Archive </span>"); }); </script>'; } } } add_action('post_submitbox_misc_actions', 'custom_post_status_submitbox_misc_actions');
I think I need to change
$(".misc-pub-section label")
but I don’t know how. I tried without label$(".misc-pub-section")
but then the status apears after the edit-link.Hopefully anyone can help me.
saNNNy
- The topic ‘Custom Post Status Display’ is closed to new replies.