0

Currently i used this code to hide 1.Status 2.Visibility and 3.Published option from Publish box but these code is not working on my wordpress version 5.8..please help me to solve this problem

 function hide_publishing_actions(){
    global $post;
    if($pagenow == post.php){
        echo '
            <style type="text/css">
                #misc-publishing-actions,
                #minor-publishing-actions{
                    display:none;
                }
            </style>
        ';
    }
}
add_action('admin_head-post.php', 'hide_publishing_actions');
add_action('admin_head-post-new.php', 'hide_publishing_actions');

i want to hide these 3 option publsih

2 Answers 2

0

Add this code on function.php

function wpseNoVisibility() {
  echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</style>';
}

function wpseCurrentScreenAction($current_screen) {
    if ('page' == $current_screen->post_type && 'post' == $current_screen->base) {
        add_action('admin_head', 'wpseNoVisibility');
    }
}

add_action('current_screen', 'wpseCurrentScreenAction');

Source - Original Source

3
  • already tried this code but not working.. Aug 4, 2021 at 11:09
  • Do you Have any other Idea to hide these fields. Aug 4, 2021 at 11:10
  • Why not to try Adminimize plugin?
    – VKS
    Aug 4, 2021 at 11:15
0

If using css was enough than you can do this

add_action('admin_head', 'bt_hide_publish_options');
function bt_hide_publish_options () {
    global $pagenow;

    if (!in_array($pagenow, ['post-new.php', 'post.php'])) return;
?>
<style>
    #submitdiv #minor-publishing {
        display: none;
    }
</style>
<?php
}

Add this to your functions.php and thats it

This code

if (!in_array($pagenow, ['post-new.php', 'post.php'])) return;

Will check if you are in post, either a new post or an existing one, if you are not in any of those this code will not execute

1
  • css is worked for me thank You Soo Much Aug 12, 2021 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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