Archived topic
how to include jquery
9 replies · Started by david on July 29, 2019
Hi, I'd like to include the following jquery into my sites home page:
$(".test").chosen({
search_contains: false,
enable_split_word_search: false
});
Please can you explain exactly where and what I need to insert for this to work
Thanks
David
Hi there,
simplest way is to add the script to a Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Add the script like so:
<script>
jQuery(".test").chosen({
search_contains: false,
enable_split_word_search: false
});
</script>
Select the WP_footer hook from the list and set your display rules to the Front Page.
Hi David,
Thanks for this, how do I "set your display rules to the Front Page."
Thanks
David
When editing the Hook element - go to the Display Rules tab - Select Location: Front Page.
Hi David,
Don't see a "Display rules tab"
Only options I see are Execute PHP, Disable Hook and Save Hooks
Thanks
Aah ok - looks like you're still using the old Hooks module. You can enable Appearance > GeneratePress > Elements module then you should see Appearance > Elemements and they will have a Display Rules tab.
Any old Hooks or Page Headers will appear in the Elements module under legacy.
I now have Appearance > Elements, but all I see at the top of the page is:
Add New, Legacy Page Headers, Legacy Hooks
Clicking Legacy Hooks brings up my wp-footer hook
Click Add New > Hook.
This document shows the Hook Element settings:
https://docs.generatepress.com/article/hooks-element-overview/
ok, so now where do I put
<script>
jQuery(".test").chosen({
search_contains: false,
enable_split_word_search: false
});
</script>
Do I place it in the empty box (with no title) above the settings bar
Below the 'Add New Element' is the Title field, followed by the content field, where you add that code, which is above the settings bar
