Home > plugins > how to include a simple jquery file into a wordpress plugin

how to include a simple jquery file into a wordpress plugin

February 17Hits:2
Advertisement

ok this is my first time to include jQuery into wordpress and it has taken me the 2 full days trying to figure this out. No matter how many articles I read I cannot find a perfect example.

Ok so this is my plugin file... very simple.

<?php     /*     Plugin Name: jQuery Include Test     Plugin URI: http://jquery.com     description: A test to include jQuery.     Author: blah blah     Author URI:      */   // jQuery alert to pop up when the page loads.      function pop_jquery_test() {     $src = plugins_url('includes/jquerytest.js', __FILE__);     wp_register_script( 'jquerytest', $src );     wp_enqueue_script( 'jquerytest' );     wp_enqueue_script( 'jquery' ); } add_action('init','pop_jquery_test');  

and this is the jquerytest.js file that

$j=jQuery.noConflict();  $jQuery(document).ready(function(){   alert('hi there'); }); 

now the question is how do i get this to work? in the sense when i activate the plugin, it pops-up like the jquery code above says.

Answers

Your jQuery is wrong. what you want is jQuery(docu.... not $jQuery(docu....

You should try to make sure the components work individually before you put them together (within reason of course), it will make troubleshooting MUCH easier for you.

Tags:php, jquery, plugins

Related Articles

  • how to include a simple jquery file into a wordpress pluginFebruary 17

    ok this is my first time to include jQuery into wordpress and it has taken me the 2 full days trying to figure this out. No matter how many articles I read I cannot find a perfect example. Ok so this is my plugin file... very simple. <?php /* Plugin

  • Does Google detect files in the Wordpress plugin directoryJune 4

    Will Google detect files in the Wordpress plugin directory? Example: /wp-content/plugins/random-image-gallery-with-fancy-zoom/js/ /wp-content/plugins/revslider/rs-plugin/videojs/demo.html I put blank index.php's on the folder and directory, and a met

  • Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress PluginOctober 5

    I'm trying to write to an XML file in a WordPress Plugin. I'm on my local machine, a Mac running MAMP. I have PHP 5.2.13 My code is: $file_handle = fopen('markers.xml', 'w'); $stringdata = "Test Info"; fwrite($file_handle, $stringdata); fclose($

  • How to add a javascript file to my wordpress plugin?January 27

    I want integrate a share button to my wordpress plugin, I know there are many plugins that will do it, but I just want a button at the end of a specific page. I added this to my controller, the one that loads/registers the rest of the javascripts, bu

  • A real way to override BuddyPress files in a WordPress pluginAugust 24

    Is there a working (must be) way to override BuddyPress template files in via a WordPress plugin. I know it can be done using a theme, but is it possible to do it with a plugin? I'm really eager to create something from it, but can't find how to do t

  • Include a external PHP file into a Wordpress Custom TemplateAugust 26

    Is this even possible? I mean, im trying to add a blog into my site.. I already have the header,footer and sidebar layout in my site. can i use those in my custom wordpress template? <?php /* Template Name: Blog */ ?> <?php include( PATH . 'http:

  • Is it possible to check is loaded language files correctly with WordPress plugin?November 16

    I have a plugin to be translated. I have done following tasks: 1. Loaded the TextDomain $my_td = 'mysignup'; function my_signup_textdomain_init() { load_plugin_textdomain( $my_td, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } add

  • Include js file in Page Layout, after jQuery file in Master PageMay 21

    I'm trying to include a javascript file in my page layout file. I already have it inside the "PlaceHolderAdditionalPageHead" Content Placeholder, and it includes the file, however I need it to be included after the jQuery file that is included i

  • pass from my php code a value to my jquery fileApril 6

    I want to pass from my php code a value to my jquery file(both in a plugin code). I managed to do it with simple variables with wp_localize_script() but I'm stack with passing class value(that should be used as a selector in the jquery). Can somone h

  • Instantiating a wordpress plugin class off of a file other than the plugin fileJanuary 29

    I have created a wordpress plugin that is made up of 3 classes, a master class, then two child classes. In one of the child classes I enquque a script that will fire off a $.post request to another php file that is also in the root directory of my pl

  • How to include this jQuery File in wordpress?February 17

    Ok I have this jQuery that I have tested in a static html page and it works fine. How would I include jQuery to work on wordpress in a plugin? So this is the html page. <head> <title> Welcome to my page</title> <link rel="stylesh

  • how to include other jquery file and css file in wordpress pluginsJune 20

    I have jquery file like as follows "portfolio.css" "jquery-ui-1.8.18.custom.css" "portfolio.js" I want to include these files into my plugin... if anyone have solution for how to include above mentioned file into wordpress pl

  • how to include multiple jquery filesJuly 8

    is it possible to include multiple jquery files like this one ? (function ($) { Drupal.behaviors.mymodule = { attach: function(context) { //my code } } }(jQuery)); I use this to include the files drupal_add_js(drupal_get_path('module', 'mymodule') .

  • rsync options to include only simple filesFebruary 10

    We intend to use a cron task to rsync files from one machine to another. Requirements are simple: File source is exactly one directory, and destination is one directory on the target machine Must allow only simple files, no symlinks, no directories A

  • 10 jQuery File Upload Plugins

    10 jQuery File Upload PluginsJune 9

    10 Awesome jQuery File Upload Plugins to upload files ajax style'y. Today I have collected top 10 excellent jQuery upload plugins which are cool and easy to integrate to upload files to your forms or web pages. Enjoy! :) Related posts: 10 Jquery Ajax

  • Developing a Simple jQuery Game to Improve Your MemoryJanuary 11

    This tutorial will show you how to create a simple game using jQuery and HTML. The resulting game is intended to help you improve your memory skills. We will have an 8×6 grid of squares as the game window. Once you start the game, images of birds wil

  • Creating a simple XML file using pythonAugust 31

    What are my options if I want to create a simple XML file in python? (library wise) The xml I want looks like: <root> <doc> <field1 name="blah">some value1</field1> <field2 name="asdfasd">some vlaue2</f

  • 10 Advanced but Simple jQuery Plugins

    10 Advanced but Simple jQuery PluginsJanuary 3

    Today's post introduces 10 advanced and yet simple jQuery plugins that will enhance your web experience drastically and will give developers the chance to enrich websites with amazing elements without the need to write heaps of code. Enjoy! Related P

  • Including a different jQuery version only on specific pageDecember 23

    jQuery update module is including this script. <script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?6"></script> I need this on every page, except a certain template file which I am usi

  • Unable to compile simple Less file using node-lessJanuary 1

    I'm trying to compile a very simple less file which simply includes Bootstrap: /* application.less: The most awesomely complicated file in the whole world. */ @import "bootstrap/bootstrap.less"; I'm on an Ubuntu 12.04 derivative and I've tried u

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.893 s.