Help for narrow down the options of the publish box.

Hello for all,

I need to narrow down the options of the publish box. I was using css (display: none) and it was working, but changed all kinds of posts. Now I need to have only the "publish button" and no other options on a custom post type, so I can not use css to do this. (I need to have all publish options in page and posts.)
Could someone help me do this another way?

One thing more:
I have to change the button label from publish to "save". Normally, I'd do it in the translation file, but maybe there is an easier way to do this.
There are a lot of "publish" in translate file. It´s not easy find out what is the right one.
I would be very happy to know how to do this too.

thanks in advance

Paulo 7

  • Dharmendra

    Hello Paulo,

    I hope you are well today and thanks for posting on the forums.

    You can add below mentioned code in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder with that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a PHP start tag at the beginning of the code.

    function hide_publishing_actions(){
    	$my_post_type = 'yourcustomposttype';
    	global $post;
    	if($post->post_type == $my_post_type){
    		echo '
                    <style type="text/css">
                        #misc-publishing-actions,
                        #minor-publishing-actions{
                            display:none;
                        }
                    </style>
                ';
    	}
    }
    
    function change_publish_button( $translation, $text ) {
    	if ( 'yourcustomposttype' == get_post_type())
    	if ( $text == 'Publish' )
    	return 'Save';
    
    	return $translation;
    }
    add_action('admin_head-post.php', 'hide_publishing_actions');
    add_action('admin_head-post-new.php', 'hide_publishing_actions');
    add_filter( 'gettext', 'change_publish_button', 10, 2 );

    Please note that you will need to replace the word 'yourcustomposttype' with your custom post type.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Take care and have a fantastic day! :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.