Put it in the Template file of the Theme.
There’s a page there called single.php.
Also, a page called post.php.
Put your scripts there.
I am new at this but what exactly would that look like. Thank you for such quick respond.
It depends on the script you use.
What is the script?
I am not sure if I am asking this correctly but I just need a real life sample that I can follow. Could you write a script with the conditions that I listed in the very beginning? Thank you.
Put it in the Template file of the Theme.
Thus open the Theme directory > wp-content > themes > ThemeName
There’s a page there called single.php. This is a single page.
Also, a page called post.php. This is a single post.
Put your scripts on this page, as if it is a fresh PHP page.
Good luck.