How to change a discount code monthly the easy way

I’m new to programming, apologises if this question is in the wrong sector.

I’m running an affiliate site that offers a 5% discount code to use on the merchant site when making a purchase.
The code is (or will be) next to multiple products across the site. This means when the code changes (on a monthly basis) I have to go through the all the webpages manually changing the discount code html.

Is there a smarter way to do this with programming, so you possibly only have to change the code in one place and it will change the code site wide?

Not if they are HTML files. Your best bet is a text editor that can do site-wide string replaces.

You could convert all the pages to PHP or equivalent, then you could do what you want. But this could mean a lot of work depending on how many HTML files you have and having to update all the links on the pages.

Since you’re running an e-commerce site I assume you have a database somewhere and there is a 3rd party or customised CMS for the site.

You have a few options and they include

  1. updating the discount in the database via the CMS. The web pages get the discount value from the database.

  2. store the discount in a session variable in a require_once() file.

Should have mentioned this earlier, I’m using wordpress and the site is not an e-commerce site. It just an affiliate site then sends people on to the main purchase website. I don’t think there is a function in the standard wordpress editor but I think theres a “search and replace” plugin. I will look in to No. 2 point though Kalon.
Just the knowledge of what this kind of editing is called “site-wide string replaces” is very useful as I can research it now much more easily.