Home > OS >  Remove the preview, view button and permalink to custom post admin using functions.php
Remove the preview, view button and permalink to custom post admin using functions.php

Time:03-21

I have a custom theme with custom post. I like to remove the preview/view button and permalink on the default post admin using functions.php.

here is my code in default custom post

////////////////////Change the default post to "新規求人登録"////////////////////
function Change_menulabel() {
global $menu;
global $submenu;
  $name = '新規求人登録';
  $menu[5][0] = $name;
  $submenu['edit.php'][5][0] = $name.'';
  $submenu['edit.php'][10][0] = '新しいお知らせを追加';
}
function Change_objectlabel() {
  global $wp_post_types;
  $name = '新規求人登録';
  $labels = &$wp_post_types['post']->labels;
  $labels->name = $name;
  $labels->singular_name = $name;
  $labels->add_new = _x('追加', $name);
  $labels->add_new_item = $name.'の新規追加';
  $labels->edit_item = $name.'の編集';
  $labels->new_item = '新規'.$name;
  $labels->view_item = $name.'を表示';
  $labels->search_items = $name.'を検索';
  $labels->not_found = $name.'が見つかりませんでした';
  $labels->not_found_in_trash = 'ゴミ箱に'.$name.'は見つかりませんでした';
}

add_action( 'init', 'Change_objectlabel' );
add_action( 'admin_menu', 'Change_menulabel' );

CodePudding user response:

hi @shouu you can hide the preview button and its permalink through this code

function hide_publishing_actions(){
    $my_post_type = 'post';
    global $post;
       if($post->post_type == $my_post_type){
          echo '
             <style type="text/css">
                #edit-slug-box,
                #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');
  • Related