JavaScript Libraries in WordPress

This is how you should do this: function my_scripts_method() { wp_enqueue_script( ‘pikachoose’, // this is your custom name for this JS lib get_stylesheet_directory_uri() . ‘/js/pikachoose/jquery.pikachoose.min.js’, // this is the url address of it’s file (let’s say you put it in your theme directory under /js/pikachoose/ directory array( ‘jquery’ ) // it depends on jquery ); … Read more

Load content dynamically & resize event

Remember that PHP (wordpress) run on server, javascript run on browser. So, what you intend is: load an url of your site (a GET request is sended to server) Server respond with a minimal html containing enquire.js and your script with enquire.register stuff enquire.js recognize resolution and run a js function the function triggered by … Read more

Load page HTML content through AJAX

An AJAX request is a request from a client like any other request. Just request the URL like normal, but with Javascript. As far as that goes, this should be simple. If you’ve done item #2– “I’ll wrap the header/footer/sidebars…”– correctly there should be no problem except that page specific functions won’t run. That is … Read more

javascripts files not linking to my category slugs?

Relative URLs are best avoided in WP, so use absolute URLs instead. Also, you should load javascript files using the correct method, ie by using the wp_enqueue_script() function hooked to the wp_enqueue_scripts action hook. Doing both of these things will sort out your issue. Using wp_enqueue_script() will also allow you to define dependencies so, for … Read more

Get content from WordPress posts in Boostrap modal window – Javascript side?

Since I’m guessing you’re not rendering that Javascript file with PHP, you’ll need to send the ID of the post to that anonymous function using something other than PHP. You could use a data attribute in your #clickme <a> like data-id=”<?php the_ID(); ?>” and then change your on click to: $(document).ready(function(){ $(“#clickme”).on (“click”, function(){ $(“#myModal-” … Read more

Problem after upgrade to 3.6.1

You should make a backup of your site before any change, including the updates of the WP core, so you can restore if anything goes wrong. That is a gold rule that every webmaster should know. It is possible that you have learnt this lesson just now. Also, it is a good practice to have … Read more

how to request a script more than once in wordpress

When you’re using wp_register/enqueue_script(), you’re basically pushing an element to an array named global $wp_scripts. Therefore you can’t echo something twice as WordPress successfully prevents scripts being registered or added multiple times. The reason is easy: Else, every plugin that registers or enqueues jQuery (or uses it as dependency) would add another instance. Which would … Read more

Parse wordpress blog data using json api and ajax

Got this working: Added html += ”; html += ‘<li>’; html += ‘<a href=”‘ + entry.link + ‘”>’; html += ‘<div class=”entry”>’ + entry.title + ‘</div>’ ; html += ‘<div class=”entry”>’ + entry.author + ‘</div>’ ; html += ‘<div class=”entry”>’ + entry.publishedDate + ‘</div>’; html += ‘<div class=”entry”>’ + entry.contentSnippet + ‘</div>’; html += ‘</a>’; … Read more