7 posts
  • Asia/Pacific Region
  • Exclusive Author
  • Has been a member for 0-1 years
giring says

How I can use a custom .js file or JQuery in my theme for themeforest? is this good idea? : if (!is_admin()) add_action(“wp_enqueue_scripts”, “my_jquery_enqueue”, 11); function my_jquery_enqueue() { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “) .”, false, null); wp_enqueue_script(‘jquery’); }

279 posts
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Has been a member for 1-2 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
PrimaThemes says

Please read this, http://support.envato.com/index.php?/Knowledgebase/Article/View/472

3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress.

4. Authors are not allowed to deregister the default version of jQuery and load another one.

7 posts
  • Asia/Pacific Region
  • Exclusive Author
  • Has been a member for 0-1 years
giring says

Please read this, http://support.envato.com/index.php?/Knowledgebase/Article/View/472
3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress. 4. Authors are not allowed to deregister the default version of jQuery and load another one.

thanks Prima I Read it But How I Do This : 3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress.

279 posts
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Has been a member for 1-2 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
PrimaThemes says
do not use
wp_deregister_script('jquery'); 
wp_register_script('jquery', 'your custom jquery');
wp_enqueue_script('jquery'); 

always use

wp_enqueue_script('jquery');

it will automatically load the default jquery on WordPress (except a plugin override it)

7 posts
  • Asia/Pacific Region
  • Exclusive Author
  • Has been a member for 0-1 years
giring says

ok .then I use “wp_enqueue_script(‘jquery’); “ for jQuery.

for other .js file I can use “wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, ‘your custom jquery’); wp_enqueue_script(‘jquery’); “?

279 posts
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Has been a member for 1-2 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
PrimaThemes says

for other .js file I can use … ?

what do you mean by other .js file here?

7 posts
  • Asia/Pacific Region
  • Exclusive Author
  • Has been a member for 0-1 years
giring says

some times i read my functions in .js file or maybe use other .js file for example a .js file of a slideshow

38 posts
  • United Kingdom
  • Exclusive Author
  • Bought between 1 and 9 items
  • Has been a member for 1-2 years
Makins says

Usually your functions.php would contain something like this to register a slider:

wp_register_script( 'slider', get_template_directory_uri() .  '/js/slider.js' );

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'slider' );

or, you can use this, which has the dependency jQuery so you don’t need to enqueue it separately.

wp_register_script( 'slider', get_template_directory_uri() .  '/js/slider.js', array( 'jquery' ) );

wp_enqueue_script( 'slider' );

Finally in the simplest form, you can just use this:

wp_enqueue_script( 'slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ) );
by
by
by
by
by
by