Saturday, October 19, 2013

1 Use wp_enqueue_script () to insert jQuery Normally in web pages, we usually use the

5 tips to use jQuery with WordPress - WordPress Trick
Responsive HTML5 beautiful 23 Free Templates
1 Use wp_enqueue_script () to insert jQuery Normally in web pages, we usually use the <script> card and put it on the inside sonic or underneath <head> footer, but if you need to develop a own plugin you use is not satisfactory, to insert jQuery into wordpress page you just need to follow sonic the code as follows: my_init function () {if (! is_admin ()) {wp_enqueue_script ('jquery' );}} add_action ('init', 'my_init');
You can substitute any name my_init by any name you want, but you should set a unique name to avoid conflict with any plugins that also use this name. You can insert this code into the functions.php file of wordpress theme are you using, or inserted directly into the plugin file that you are developing. To better understand sonic the above code you can refer to: wp_enqueue_script () add_action () is_admin ()
2 Load jQuery from Google AJAX Library When we use wp_enqueue_script ('jquery'), sonic then WordPress will automatically load jQuery from wp-includes/js/jquery/jquery.js folder. But in some cases you do not want to load from the folder where you want to get jQuery sonic directly from Google AJAX Library, you should write like this: my_init function () {if (! Is_admin ()) {/ / comment sonic out the next two lines to load the local copy of jQuery wp_deregister_script ('jquery'); wp_register_script ('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min . js ', false, '1 .3.2'); wp_enqueue_script ('jquery');}} add_action ('init', 'my_init');
3 Place jQuery Footer default position will be located inside jQuery <head> to put it on the bottom of your footer using the code as follows: my_init function () {if (! Is_admin ()) {wp_deregister_script ('jquery'); / / load the local copy of jQuery in the footer wp_register_script ('jquery', '/ wp-includes/js/jquery/jquery.js', false, '1 .3.2', true) / / load the Google API or copy in the footer sonic / / wp_register_script ('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1 .3.2 ', true); wp_enqueue_script (' jquery ');}} add_action sonic (' init ',' sonic my_init ');
4 Insert a jQuery file or folder from the plugin folder of your theme Suppose you have a file. Js want to insert into the theme or plugin from the web then you can do the following: init () {if (! Is_admin () ) {wp_deregister_script ('jquery'); wp_register_script ('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1 .3.2' , true); wp_enqueue_script ('jquery'); sonic / / load a JS file from my theme: js / theme.js wp_enqueue_script ('my_script', get_bloginfo ('template_url'). '/ js / theme.js', array ( 'jquery'), '1 .0 ', true);}} add_action (' init ',' my_init ');
5 jQuey coding convention to avoid conflicts with other code, the default WordPress automatically call jQuery.noConflict ();, to convert a jQuery $ variable, so you can write the following sonic jQuery statement : jQuery (function ($) {/ * You can safely use $ in this code block to reference jQuery * /});
Maybe the time of writing there may be many ambiguities or confusing to the reader, so if you have any questions or comments about this article, then I hope you will leave a message in the form of comments to discuss offline.
Along Categories: Open the file upload feature for members Contributors The Admin interface to edit the WordPress page 8 for a safe way wordpress 1 page articles display many of the comments page 5 WordPress plugins need 18 wordpress plugins in helping you create Slideshow for wordpress pages WordPress Trick: How to create thumbnail for article ID How to find articles and category 4 in wordpress plugin that helps you track hits in wordpress Creating book corner effect (Peel Away) for page 5 WordPress plugins for wordpress backup in step 6 change the default prefix in wordpress layout mode automatically resize images in wordpress plugin you will speed 5 pages Top 5 WordPress plugins for creating pages related news WordPress How to share box facebook, google + Sliding Top 5 Web Pages Author Box WordPress Plugin For WordPress sonic Trick: Guide to install WordPress plugin for Views Display posts without using wordpress plugin for wordpress manual update sonic by hand
Php tricks Resizing images with PHP Create Multiple Files Upload in PHP 4 to PHP procedure starts from 3 to save the page url in PHP Creating images with PHP one digit to word converter written in PHP Create a registration page Members with PHP / MySQL procedure javacripts new way to display news News Ticker jQuery Image Slider Create flyout jQuery & CSS3 to create drag and drop functionality sonic to jQuery UI Sortable hidden effect, is content with jQuery Introduction to jQu

No comments:

Post a Comment