Comments not working (error not allowed) on posts with custom post status
Question
I was able to make a custom post status using this codes:
// Registering custom post status
function wpb_custom_post_status(){
register_post_status('rejected', array(
'label' => _x( 'Rejected', 'post' ),
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Rejected <span class="count">(%s)</span>', 'Rejected <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', 'wpb_custom_post_status' );
// Using jQuery to add it to post status dropdown
add_action('admin_footer-post.php', 'wpb_append_post_status_list');
function wpb_append_post_status_list(){
global $post;
$complete="";
$label="";
if($post->post_type == 'post'){
if($post->post_status == 'rejected'){
$complete=" selected="selected"";
$label="<span id="post-status-display"> Rejected</span>";
}
echo '
<script>
jQuery(document).ready(function($){
$("select#post_status").append("<option value=\"rejected\" '.$complete.'>Rejected</option>");
$(".misc-pub-section label").append("'.$label.'");
});
</script>
';
}
}
But whenever i tried posting a comment on the post with this post status and despite having comments enabled on post & the wordpress settings im getting this error:
Sorry, comments are not allowed for this item.
How to fix this? Or any workaround?
0
2 months
2022-11-27T10:46:31-05:00
2022-11-27T10:46:31-05:00 0 Answers
0 views
0
Leave an answer