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

Load custom field value into div with AJAX

Firstly, a POST request is the wrong type of request to send. As stated here, POST: Submits data to be processed to a specified resource You should be using GET, which Requests data from a specified resource The next problem is that in your callback function you are checking for $_POST[“pid”], but you are not … Read more

AJAX Implementation

First, enqueue your script correctly, in functions.php: function my_enqueue_scripts() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); Then, Authenticated users only (see https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)) (can also be in functions.php): function fetchData(){ // Not needed anymore, as you manage the case through the `add_action` method // if ( ! is_user_logged_in() ) { // return; // } // this can be … 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