Created
June 8, 2022 07:46
-
-
Save aslamdoctor/43b96af08531fb510ccac9222281bbd1 to your computer and use it in GitHub Desktop.
Snippet : Debug ajax response by calling it from browser url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_ajax_testttt', 'testttt' ); | |
function testttt() { | |
$our_people = new WP_Query( | |
array( | |
'post_type' => array( 'people' ), | |
'posts_per_page' => '4', | |
'post_status' => array( 'publish' ), | |
'orderby' => 'rand', | |
'meta_query' => array( | |
'relation' => 'OR', | |
array( | |
'key' => 'feature_on_homepage', | |
'value' => 'Feature', | |
'compare' => '=', | |
), | |
array( | |
'key' => 'feature_on_homepage', | |
'value' => 'Include', | |
'compare' => '=', | |
), | |
), | |
) | |
); | |
if ( $our_people->have_posts() ) : | |
while ( $our_people->have_posts() ) : | |
$our_people->the_post(); | |
the_title(); | |
echo '<br/>'; | |
endwhile; | |
endif; | |
die(); | |
} | |
add_action('init',function() { | |
if(isset($_GET['testttt']) ) | |
testttt(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment