简体   繁体   中英

Use jQuery plugin with Wordpress?

I want to show a jQuery flot graph on a WordPress blog. (EDIT: A post, just to be clear.)

I've got the flot graph working outside WordPress, but the (lack of) documentation and (millions of conflicting) forum questions about getting jQuery plugins working with WordPress are very confusing.

What do I need to do to use the flot plugin with WordPress?

I'm guessing:

  • Add a reference to jQuery somewhere in the WordPress post. Apparently jQuery is bundled with WordPress, but it's not included by default in the head, so how do I refer to it?
  • Add a reference to flot in the WordPress post. I've installed the WordPress flot plugin, but where is the actual JavaScript file? (The documentation doesn't say!)
  • Add my flot script inside document.ready - some forum posts refer to the need to change $ to jQuery when using WordPress: do I need to do this?

Thanks for this. I think someone who wrote a definitive post on "Using jQuery Plugins With Wordpress" would get a lot of very grateful traffic.

wp_register_script('flot', plugins_url('/flot/jquery.flot.min.js', __FILE__), array("jquery", "jquery-ui-core", "excanvas" ), '0.7.0');

(摘自flot.php)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM