0

I have a php page template used for all archive product categories. If I want to change the button on one of the categories, is there an 'if' 'then' condition I can put in? e.g button for all categories says 'book now' and takes them to a calendly booking page. one category is not available for booking but I still want them to be able to enquire about it. I was hoping I could add a condition where the buttons for that category would say 'Enquire' link to the contact page

https://snipboard.io/5ycTSh.jpg

1 Answer 1

2

The easiest way to do it would be:

if ( is_category ('4') ) {
 echo '<a class="btn" href="">Enquire</a>';
} else {
 echo '<a class="btn" href="">Calendly link</a>';
}

Obviously you would change "4" to whatever the specific category number is.

Also, the WordPress template hierarchy could be helpful if you have add'l changes:

https://developer.wordpress.org/themes/basics/template-hierarchy/#category

Graphical view of the Template Hierarchy

If you want a special template for the category 4, you just save the template file as category-4.php in your child theme folder.

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.