I’m trying to implement the script below to print the images on the supposed pages but it rather causes a problem to the pages instead.
<?php
if ($currentpage == '/services/') {
print("<img src="path/to/services.png" alt=""/>");
},
if ($currentpage == 'contact.php') {
print("<img src="path/to/image.png" alt=""/>")
},
else {
print("<img src="path/to/image.png" alt=""/>")
}
?>
The error message is:
Parse error: syntax error, unexpected T_STRING in /home/master/public_html/wp-content/themes/siteripe-001/othe-rpages.php on line 173
You don’t need brackets if there is only one line of code in a block.
In your case, it is more efficient to use one
ifblock withelseifandelse, rather than severalifblocks: you are always testing the same variable ($currentpage), so only ONE block will be executed.I also replaced some double-quotes with single-quotes.
Shouldn’t the second image be
contact.pnginstead ofimage.png?