- This topic has 14 replies, 2 voices, and was last updated 4 years, 5 months ago by
David.
-
AuthorPosts
-
December 17, 2018 at 2:57 pm #759596
Carsten
Hi there, I have been looking in the js folder for the the document ready block in GB to add some js code, but I can’t locate it.
Put this line inside the document ready block of your theme’s js file
Regards
CarstenDecember 17, 2018 at 5:17 pm #759677David
StaffCustomer SupportHi there,
what code are you trying to add? If it’s a jquery you can just wrap it like so:
jQuery( document ).ready( function( $ ) { script in here } );
And use the Hook Element – WP Footer Hook:
https://docs.generatepress.com/article/hooks-element-overview/
December 18, 2018 at 4:29 am #759994Carsten
Hi David, yes it is a jQuery, and I had tried to put it in a custom hook, but it doesn’t kick in.
I have posted this issue before but wanted to try another approach, copying the code directly in a js file, because the custom hook option in GP shows no effect.<script type=”text/javascript”>
jQuery(document).ready(function() {
jQuery(‘#send_message_form’).submit( function() {
jQuery(‘#subject’).val(“Some message subject”);
});
});
</script>Ps. I do not receive email on replies, despite this option is checked?
December 18, 2018 at 6:21 am #760080David
StaffCustomer SupportCan you link me to the article where it explains adding this code?
December 18, 2018 at 6:23 am #760081December 18, 2018 at 6:23 am #760082December 18, 2018 at 6:30 am #760085David
StaffCustomer SupportCan you add the script to the WP_Footer hook and set the display rules to the entire site?
December 18, 2018 at 6:46 am #760099Carsten
No difference, could you please check if the wrapping is correct?
December 18, 2018 at 6:50 am #760210David
StaffCustomer SupportThe only thing that looks a little odd are the single and double quotes. Remove them and replace them manually.
December 19, 2018 at 4:20 am #761024Carsten
Hi David, just a status update, as it turns out, the jQuery I tried to add, only works with the Buddypress Legacy template, not Nouveau. So no wonder I couldn’t make it work.
Thanks for your efforts
Regards
CarstenDecember 19, 2018 at 4:57 am #761055David
StaffCustomer SupportHaha – awesome – glad you found out the reason 🙂
December 19, 2018 at 6:50 am #761218Carsten
Just a quick question, I am going to insert code into the head section of my site, is the Header element the right place for Header Scripts like this (for PWA icon support on iOS)?
<!– place this in a head section –>
<link rel=”apple-touch-icon” href=”touch-icon-iphone.png”>
<link rel=”apple-touch-icon” sizes=”152×152″ href=”touch-icon-ipad.png”>
<link rel=”apple-touch-icon” sizes=”180×180″ href=”touch-icon-iphone-retina.png”>
<link rel=”apple-touch-icon” sizes=”167×167″ href=”touch-icon-ipad-retina.png”>Regards
CarstenDecember 19, 2018 at 6:53 am #761223David
StaffCustomer SupportThe Hook Element is the right place for adding scripts / meta etc.
Select thewp_head
hook in the element.December 19, 2018 at 6:58 am #761224Carsten
Hi Dave thanks for your quick reply, I had choose Header element instead of Hook > wp_head…
December 19, 2018 at 7:00 am #761230David
StaffCustomer SupportSome more info on the hooks element can be found here, in case you need it:
https://docs.generatepress.com/article/hooks-element-overview/
-
AuthorPosts
- You must be logged in to reply to this topic.