The first part of the code can be inserted in the body of a page/post using the HTML editor. You can also enter it in a text widget and place it anywhere your theme supports widgets.
To add the second part of your code, you will need to use a child theme and attach that code to the wp_head
action hook in your functions file.
Hi Kjodle,
Thank you for the reply,
I have created a child theme but unable to follow your instructions of ” attached that code to wp_head action hook in your functions file”, could you please provide detailed steps on how to do that, I’m fairly new to wordpress.
Thanks
Do you already have a functions file? If not, open a text editor and type:
<?php
add_action ('wp_head', 'insertminiclip' );
function insertminiclip() {
echo "<script src="http://www.miniclip.com/js/game-embed.js"></script>";
}
?>
Yes, it’s that simple. Make sure you don’t include any spaces before the opening <?php
tag or after the closing ?>
tag, or you’ll get the dreaded “Headers already sent by…” error.
Be sure to use a real text editor (i.e., Notepad++ or something similar), save the document as functions.php
and upload it to your child theme folder.
Let me know if you have problems.
Hi Kjodle,
appreciate your reply,
I added the funtions.php file as you have suggested, now my child theme folder has two files funtions.php and style.css linking to parent theme, I followed the this link to create child theme, also added the top part of the code to post in the HTML segment however the game doesnt seem to appear on the post, could you please look in to it and suggest what could possibly be missing.
Thank you
now my child theme folder has two files funtions.php and style.css linking to parent theme
Yes, that’s correct. A style.css
is all that’s really needed; the functions.php
is optional.
I can’t really guess as to why it isn’t working without seeing a link to your site.
I’m still struggling to get it to work, i have not hosted the site yet so cannot share the link if you point me to any direction for further research it will of a great help to me.
thanks
Try using your browser’s “View Source” function to see if that code above is actually being added to the <head>
element of a page.