Target only single product page

At first sorry for my bad English! I try to hide #mceu_27-body and #wp-content-editor-tools on products page (editing mode) like on the pics for certains authors! This work find :

    add_action('admin_head', 'wwc_my_custom_css');
if (!current_user_can('edit_pages') ) {
function wwc_my_custom_css() {
     echo 'style
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          /style';}
}

But it affect all posts type and I just want it on products post type so I tried that but it doesn't work :

add_action('admin_head', 'wwc_my_custom_css');

if (!current_user_can('edit_pages')  is_product() ) 
function wwc_my_custom_css() {
     echo 'style
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          /style';}
}

Thx

Topic woocommerce-offtopic post-type posts Wordpress

Category Web


I assume you mean to use this on a single product's page, right? If so, try this:

add_action('admin_head', 'wwc_my_custom_css');

function wwc_my_custom_css() {
if (!current_user_can('edit_pages'){
   global $post;
   $isProduct = $post->post_type == 'product'; // use the actual name for product

   if ($isProduct ) {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';
     }
  }
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.