Programming links with php

Hello,
I am new to php.
I want to know if it’s possible using php to display a different link on a page depending on what product it is.
EG: A shop sells promotional products and for each product they want to offer a different link to a relevant template and have it display on the product page.
Instead of me having to manually enter all these links can I set up an “if” or “switch” statement so that it happens automatically?.
I might add that this is for a word press shop.

Yes, you can do that. To help you out, WordPress has a long list of conditional tags. You should find one there that is suitable for your needs.

Try using a switch statement. If you are having problems getting it to work properly, post the code here and someone should be able to help you out with it.

Thankyou for your response.
I’ll try and do this even though I don’t know where to start!
I guess you’ve pointed me in the right direction though.
I guess I’d be writing the switch and sticking it into the child themes functions.php .
Thanks!

We can help you as you go along, so don’t hesitate to ask. But it’s so much nicer helping someone with their efforts rather than doing the job for them. :wink:

By the way, are you using the WooCommerce plugin?

1 Like

Understandable. Yes I am using the Woocommerce plugin.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.