Ajax Load More Posts in Category Page

Your query parameters don’t contain any category arguments. You need to pass and set cat or category_name along with the post type, offset, and posts per page. You can get the current category’s ID via get_queried_object(): $queried_object = get_queried_object(); $cat_id = $queried_object->term_id; Output and retrieve the value somewhere in your category template, or better, when … Read more

Nonces and Cache

I know this question is ancient, but no, it’s not very secure. Anyone with knowledge of the AJAX endpoint would be able to generate valid nonces, which defeats the purpose in the first place. That being said, nonces are a low level defence in the first place: they only stop the simplest of attacks. A … Read more

What is the simplest ajax upload plugin or script to be used with wordpress?

I have used the native uploader with great results. Try adding this snippet of JS: jQuery(‘#upload_image_button’).click(function() { formfield = jQuery(‘#fwpPhoto’).attr(‘name’); tb_show(”, ‘media-upload.php?type=image&amp;TB_iframe=true’); return false; }); window.send_to_editor = function(html) { imgurl = jQuery(‘img’,html).attr(‘src’); jQuery(‘#fwpPhoto’).val(imgurl); tb_remove(); } Then, in your HTML: <input id=”fwpPhoto” name=”facultyPhoto” value=””> <input id=”upload_image_button” type=”button” value=”Upload Image”> For Multiple Uploaders <input id=”facultyPhoto-1″ name=”facultyPhoto-1″ value=”” … Read more

How to add to cart via AJAX Woocommerce [closed]

are we talking about the single product view or the product archive pages (shop,categories)? because the text beside the checkbox/option states, roughly translated: »activate ajax-checkout-button on product archive pages« and on all the installations i did so for, that is the way its working – ajax checkout on the archives, but not on the single … Read more

WP List Table custom quick edit box – post meta data missing and columns change on submit

I just run in the same error when adding extra columns to the default post types. The offending line was the $pagenow check. Quick Edit uses admin-ajax.php so it doesn’t renders the custom columns when it’s done. This doesn’t work: if( ‘edit.php’ == $pagenow && is_admin() ) { add_action( ‘admin_init’, array( $this, ‘init_id_column’ ), 999 … Read more

Ajax and autocomplete

Use jQuerys getJSON in the autocompletes source method and use WordPress’ admin-ajax.php to handle the request, to avoid having to find wp-load.php (which may have been moved) and would load WordPress on every request. First of all: get the ajax url of your WordPress blog: This is simple: admin_url( ‘admin-ajax.php’ ) But, we want this … Read more