1

I need to hide the name in the category box from a specific page. I need to show the name in all other pages but this one. Is there a way to use this CSS for a specific category? Thank you!

.box-text-inner { display: none; }

3
  • Find the class on body. Each pages have a diffrent classess. Target your element with body something like this Example : body.page-id-61700 .box-text-inner{ display: none; }
    – Zeshan
    Jul 13, 2021 at 8:08
  • Look at the body's classes. You should be able to find a unique class, or two combined classes to have a unique result. So example body.tax-product_cat.term-36 is the unique class of the category page with category id 36. So if you enter something like body.tax-product_cat.term-36 .box-text-inner { display: none; } you will hide the .box-text-inner for the specific category page
    – vadims
    Jul 13, 2021 at 8:12
  • Thank you both guys, problem solved in a moment! Thank you very much
    – Pees
    Jul 14, 2021 at 15:42

1 Answer 1

0

Let's assume you have a custom page with the name/title "Hello". and add the following code to your themes functions.php or you can also create your own plugin.

Code snippet:

   function my_custom_page_category_hide(){
    $page_title = $wp_query->post->post_title;
    if($page_title=="Hello"){
    echo '<style>
        .box-text-inner { display: none !important; }
        </style>';
    }
  }
   add_action( 'wp_head', 'my_custom_page_category_hide' );

Just paste the above code and do check the priority of your custom css code. In case of any issues let me know in the comment.

7
  • Hello Rajneesh and thank you for your help. The snippet didn't work probably because it's not a custom page with a title but a woocommerce category page. Here's the page link so that you can understand my problem more clearly. romasecondapelle.it/categoria-prodotto/figurine-panini The images already have the name so i need to hide the title under the image box.
    – Pees
    Jul 14, 2021 at 8:51
  • Ok, on my same above code try to add this solution, stackoverflow.com/questions/8829632/… check for the category id where am checking $page_title , this might help you. Jul 14, 2021 at 9:38
  • is my above comment solution worked for you? Let me know so that I can update my answer accordingly. please post what function you used in the place of $page_title Jul 14, 2021 at 10:44
  • Sorry Rajneesh i tought it worked but no. I'm sorry because the problem is that i do not know php so i wrote the function wrong. "function my_custom_page_category_hide(){ $page_title = $wp_query->post->post_title; if($category_id=="60"){ echo '<style> .box-text-inner { display: none !important; } </style>'; } } add_action( 'wp_head', 'my_custom_page_category_hide' );"
    – Pees
    Jul 14, 2021 at 14:24
  • ok no issues, I will run the code the same code on my local system and will update you about that. Hope I find the solution. Jul 14, 2021 at 17:38

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.