How to run a PHP snippet only on the pages where I need it?

[ad_1]

Hello,

I added a PHP snippet to hide the page titles on my category archive pages like this one here: https://mayangateway.com/category/guatemala-tours/ as you can see in this page, it works, the title is hidden.

However, I want to run the PHP snippet only on my category archive pages, not in the entire website. I tried to do the following options:
1. Auto Insert → Frontend Conditional Logic + Enable Logic → Conditions → Show Page URL → is (a few rules with the pages where I need the snippet)
2. Auto Insert → Frontend Only + Enable Logic → Conditions → Show Page URL → is (a few rules with the pages where I need the snippet)

After doing each combination, I erased all caches. But none of those options work. At the moment I am using: Auto Insert → Frontend Only without enable logic to make it work.

Here is the PHP snippet:
add_action( 'wp', 'lh_remove_archive_title' ); function lh_remove_archive_title() { remove_action( 'generate_archive_title', 'generate_archive_title' ); }

How can I run the PHP snippet only in the pages where I need it?
Thank you in advance for your help.

  • This topic was modified 3 hours, 1 minute ago by Josue Ardon.

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer