Basic WordPress AJAX Call

WordPress AJAX uses actions to connect your jQuery action with a traditional WordPress action. Take a look at the example WordPress provides in their docs. There’s 2 hooks: add_action( “wp_ajax_{$jquery_action_string}”, “callback_function_name” ); The above will only work for authenticated ( logged in ) users. For non-logged-in users we use nopriv: add_action( “wp_ajax_nopriv_{$jquery_action_string}”, “callback_function_name” ); So … Read more

Proper way to load a single post via Ajax?

Here is my view: Load it inside your single.php why use ajax at all? Google wont be able to see this (using most crawlers). In any case – here is the right way to return the data… please note that you can use get_post or wp_query. up tp you. JS Part: jQuery(document).ready(function($) { $.post(ajax_object.ajaxurl, { … Read more

Adding fields to the media uploader with jquery listeners

From Blackbone.js website: render is the core function that your view should override, in order to populate its element (this.el), with the appropriate HTML. The convention is for render to always return this. So, I have modified the code a little bit to add jQuery change listener. function add_gallery_type_option(){ ?> <script type=”text/html” id=”tmpl-my-custom-gallery-setting”> <label class=”setting”> … Read more

Passing a varible from jQuery to PHP

First, don’t use query_posts. Second… I think this can be done with AJAX but is there a more simple method and give me a clean URL? PHP runs on the server. Items are “clicked” on the client machine. The only way to pass that “clicked” value back to PHP is via AJAX. Within a WordPress … Read more

Is it worth updating WP admin to jQuery 1.5?

Well, as for performance release post says: In this release we’ve also been able to improve the performance of some commonly-used traversal methods: .children(), .prev(), and .next(). The speed-ups that we’re seeing are quite substantial (potentially many many times faster, depending upon the browser). On other hand replacing jQuery on admin side is rarely good … Read more

Javascript included but alert() function not working

A few things: The version of jQuery that ships with WordPress is run in noConflict() mode. Meaning you have to use jQuery instead of $ when you make your first reference. Don’t register your own version of jQuery when you’re developing. You’re locking yourself in to a single version that may or may not be … Read more