Archived topic
how to put "my code" into footer.php without being deleted after updates?
5 replies · Started by Dmitry Bychenko on March 15, 2016
Hi,guys,
i put a script into footer.php, but after update footer.php got replaced by a new footer.php which is ok.
for now i pout this script again into new footer.php and waiting for a new update:)
i tried to put this script into wp_footer hook (im not advanced html css php whatever coder) i dont even know if it should work that way, but it didnt work.
how to avoid script to be deleted from footer.php?
Hi there,
If you have GP Hooks you can add it into the wp_footer hook in "Appearance > GP Hooks".
If not, you'll need to use a function like:
add_action( 'wp_footer','generate_my_custom_wp_footer' );
function generate_my_custom_wp_footer()
{
?>
Add your stuff in here
<?php
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Hope this helps :)
Thanks, Tom,
yes, i have GP Hooks (Premium), i tried to put stuff there, but it didnt work. and i checked Execute php.
the script is:
<script type="text/javascript" src="http://tradebonds.ru/simplebox_util.js"></script>
<script type="text/javascript">
(function(){
var boxes=[],els,i,l;
if(document.querySelectorAll){
els=document.querySelectorAll('a[rel=simplebox]');
Box.getStyles('simplebox_css','http://tradebonds.ru/simplebox.css');
Box.getScripts('simplebox_js','http://tradebonds.ru/simplebox.js',function(){
simplebox.init();
for(i=0,l=els.length;i<l;++i)
simplebox.start(els[i]);
simplebox.start('a[rel=simplebox_group]');
});
}
})();</script>
Script should be put before </body> in footer.php
what is the correct way to put it in wp_footer?
Adding it into wp_footer should be all that is needed.
If it's not working still, there must be some sort of issue with the code itself I'm afraid.
Thanks, Tom,
the strange thing is now it's working. it didnt work when i tried it first time.
maybe ive done something wrong last time.
sorry for that.
anyway, im very happy with GP and your support, thank you!
Great, glad it's working now :)
