Add Infinite Scroll to Ajax Loaded Category Query

Update … Here’s the Final Code That Worked for Me This may not be perfect, but it seems to be working well for me with no errors. Feel free to add any suggestions for improvement if you have any. JS Code jQuery(document).ready(function($) { var count = 2; jQuery(“#la-chooser”).change(function() { loadArticlebyCat(this.value); }); function loadArticlebyCat(cat){ data = … Read more

Class WP_Rewrite not found

I can fixed the problem including this files: require( ABSPATH . WPINC . ‘/class-wp-rewrite.php’ ); require( ABSPATH . WPINC . ‘/class-wp-user.php’ ); require( ABSPATH . WPINC . ‘/class-wp-tax-query.php’ ); require( ABSPATH . WPINC . ‘/class-wp-meta-query.php’ ); require( ABSPATH . WPINC . ‘/class-wp-term.php’ ); require( ABSPATH . WPINC . ‘/class-wp-post.php’ ); require( ABSPATH . WPINC . … Read more

How do I call wp_mail from HTML?

First the way to do this is with a form using the post method, it is slightly easier to understand: <!– form with AJAX action and iframe target –> <form method=”post” action=”<?php echo admin_url(‘admin-ajax.php’); ?>” target=”emailsendframe”> <!– AJAX action field to trigger function–> <input type=”hidden” name=”action” value=”download_email_send”> <!– Post ID field –> <input type=”hidden” name=”intro” … Read more

How to use wp_send_json_error?

wp_send_json_error( ‘Error: Invalid data!’ ) Will echoes a JSON string: {“success”:false,”data”:”Error: Invalid data!”} The nice thing about wp_send_json_error() is, the parameter could also be a WP_Error object. As opposed to wp_send_json_success( ‘Everything okay.’ ) which echoes this JSON string: {“success”:true,”data”:”Everything okay.”} Both rely internally on wp_send_json() to echo the JSON data properly and die() afterwards. … Read more

Ajax loop refresh on click

Shouldn’t be too tricky. First: create a javascript file and add this: jQuery(document).ready(function($){ $(‘#refresh-links-id’).click(function(e){ e.preventDefault(); $.post(ajaxurl,{action:’jpb_random_loop’}, function(data){ $(‘#content-inner’).fadeOut(250).empty().append( data ).fadeIn(250); }); }); }); Save that file in your theme directory somewhere (could be in a subdirectory too). For this to work, the refresh link should not be inside ul#content-inner. Pretty basic jQuery post call, though. … Read more

Can’t use get_results() in ajax query

This will not work because you call example.com/markers.php directly, and that file does not load anything from WordPress, like the $wpdb object. You can include wp-load.php, but this might break if you move the WordPress installation to somewhere else. To be more in line with how Ajax calls in WordPress should be made, you should … Read more