Getting featured image from WP_Query

Suggest to reformat the data like such (untested): function load_more_blogs() { … $results = array(); foreach ( $query->posts as $post ) { $results[] = array( ‘post’ => $post, ‘image’ => get_the_post_thumbnail( $post->ID, ‘post-thumbnail’ ), ); } wp_send_json_success( $results ); exit(); } This will give you an array of arrays, with the inner array have two … Read more

Object name undefined using localize script

I think it’s because you’re doing your localization in the shortcode which may be messing with the order of things. Instead do this: add_action( ‘wp_enqueue_scripts’, array( $this, ‘frontend_enqueue’ ) ); function frontend_enqueue() { wp_register_script( ‘my-handle’, plugins_url( ‘js/frontend.js’, __FILE__), array( ‘jquery’ ), ‘1.0.0’, true); wp_localize_script(‘my-handle’, ‘ajax_actions’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) )); } Then… add_shortcode( … Read more

How does the security of admin_ajax.php work?

If you look at the source of admin-ajax.php, the answer becomes clearer: $action = $_REQUEST[‘action’]; if ( is_user_logged_in() ) { // If no action is registered, return a Bad Request response. if ( ! has_action( “wp_ajax_{$action}” ) ) { wp_die( ‘0’, 400 ); } /** * Fires authenticated Ajax actions for logged-in users. * * … Read more

error code: 523