wordpress admin ajax trash_comment

The way you’re adding parameters to the url isn’t working. The ajax request is designed to prevent parameter insertion like this. I recommend you kick off another ajax request to handle this process rather than trying to hook into the existing process in this way. For example, you can kick off your modal window after … Read more

How to pass array from jQuery to PHP with AJAX in WordPress?

If assign_categories() is in a class, you have to call the action in a different way. add_action( ‘wp_ajax_assign_categories’, ‘assign_categories’ ); becomes add_action( ‘wp_ajax_assign_categories’, array( $this, ‘assign_categories’ ) ); The $this in this context is the class.

Assign author on ajax wp post insert

You’re almost there. Here’s the part that is setting the author of post to user with ID = 1: ‘post_author’ => 1, ‘post_status’ => ‘publish’, ‘post_type’ => ‘testimonial’, ‘author’ => $current_user->ID, You even try to set the author to $current_user, but you don’t initiate this variable anywhere in your code and you set author field … Read more

Get posts by category via ajax

Add the category ID to category list items <div class=”category-block” data-cid=”{ID-OF-CAT}”>, you will need it in the ajax request. You must also include action in the request and display received data. Here you can read more about AJAX in WP. blog.js (function($) { $(document).ready(function() { var cat_buttons = $(“.category-block”); cat_buttons.on( ‘click’, function(event){ // event.preventDefault(); var … Read more