Skip to content

Instantly share code, notes, and snippets.

@aslamdoctor
Created June 8, 2022 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslamdoctor/43b96af08531fb510ccac9222281bbd1 to your computer and use it in GitHub Desktop.
Save aslamdoctor/43b96af08531fb510ccac9222281bbd1 to your computer and use it in GitHub Desktop.
Snippet : Debug ajax response by calling it from browser url
<?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