• 0
Sign in to follow this  
Followers 0

JQuery Plugins - how to?

Question

Posted · Report post

Hi, So, I've been reading up a bunch and I'm still lost on this. I wish to add a jquery plugin called "advanced search" just after my nav. I think I kinda got the hook but not sure about the function since its a bit beyond me at the moment. I got the hook from here:

http://api.pagelines.com/hooks
and the video tutorial. I have added text to my header area through php just not a plugin. This is what I believe is part of what I need:
add_action('pagelines_section_after_postnav', 'advanced_search');
	
	function advanced_search(){
	
	?>
	
	<?php }
I named the function advanced search. What goes in between
?>
	
	<?php }
Is what I need to figure out. I downloaded the plugin:
http://rosanko.blogspot.com/2011/04/jquery-advance-search-slider.html
and uploaded it to here:
;
I also put this in my footer scripts area in pagelines. I've read around on pagelines and I'm thinking I may need to add something like this:
<?php
	function advanced_search() {
	// register your script location, dependencies and version
	wp_enqueue_script( 'myscript', get_theme_root_uri()."/wp-includes/js/advanced_search/js/jquery.js", array('jquery', 'swfobject'), '1.0', true);
	}
	add_action('wp_enqueue_scripts', 'advanced_search');
	?>
Does this look right? Bueller? I also got some info from here
http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Thanks

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

Posted · Report post

Ok first, fair play for having a go! Now, lets have a closer look. Your js script is in the wrong place for a start, you should never ever ever edit core wp files, or add new ones, breaks the ability to ever upgrade! So lets assume you have the base theme installed and activated we will put the theme there. so it becomes pagelines-template-theme/jquery.ryans_menu.js Now you have attemted to load your js from inside the pagelines_section_after_postnav action, unfortunately the js will never load from here with wp_enqueue because its run too late. js needs to enqueued during wp_enqueue_scripts. So that being said, your going to need to functions, one to include your js, and the other to work with it. [code]add_action( 'wp_enqueue_scripts', 'ryansmenu_js' ); function ryansmenu_js() { wp_enqueue_script( 'myscript', get_stylesheet_directory_uri() . "/jquery.ryans_menu.js", array('jquery', 'swfobject'), '1.0', true); }[/code] Now you add your second functions to do the actual munu: [code]add_action('pagelines_section_after_postnav', 'ryans_advanced_search'); function ryans_advanced_search() { // your code goes in here. }[/code] Well i hope this gives you some pointers :) good luck!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I need to figure this out as well...that is, how to include a custom jQuery script...I have two questions -- what file am i supposed to add the add_action stuff to?? also, does this also work with Pagelines 1.5?? My customer hasn't upgraded so I am still working with that...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

What kind of jQuery plugin are you trying to implement? Is it the same one? The file you're supposed to add the action to is the functions.php file. As for working with PageLines 1.5 (PlatformPro + PlatformBase), I don't see why it wouldn't work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0