Reputation: 4519
I built this simple search function for a FAQ page that displays live results and it works great locally and on jsfiddle: http://jsfiddle.net/y8mkF/7/
However, I can not get it to work on Wordpress. Here's what I've tried so far:
Inserting the html portion into Wordpress text field.
I tried putting the javascript inside the post area as well by using:
<script type="text/javascript" src="/scripts/search.js"> </script>
<script type="text/javascript">
<!--
updatepage();
//--></script>
and still it will not work. Is there a special way to put custom jQuery into Wordpress or what? It should not be this hard. I appreciate anyone's help on this. Thank you.
Upvotes: 0
Views: 83
Reputation: 362
wordpress do not allow insert script into post, you can edit your theme to include script.
Upvotes: 0
Reputation: 40639
Try this in your functions.php
file,
function load_jQuery() { // load external file
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"), false);
wp_enqueue_script('jquery');
wp_register_script('search', get_template_directory_uri() . '/_/js/search.js', array('jquery') );
wp_enqueue_script('search');
}
add_action('wp_enqueue_scripts', 'load_jQuery');
Source from Wordpress wp_enqueue_script Not Working
Upvotes: 2