I apologize for not being very clear in my previous reply @andynick. What I meant was that the sample code you shared was using incorrect syntax and was just not going to work no matter what.
First of all, if you are adding the code via Code Snippets, you can ignore the add_action( 'wp_head', function () )
part. Code Snippets will just execute it for you.
Second, for reference, the <script> tags are only used with JavaScript code (you are using PHP here) you will want to keep all the PHP code within the correct tags
<?php
// your php code goes here
?>
If you are writing PHP code in the future and are unsure wether the syntax is correct, you can use a free online syntax checker such as this one here https://phpcodechecker.com/
I am not quite sure what could be preventing the code from working on your end. I have recorded this short video illustrating the multiple steps in the hope that it will help us spot what could be different.
I am hoping that will help!
-
This reply was modified 2 years, 4 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 4 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 4 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 4 months ago by Alvaro Gómez.