jQuery(function($){
$.ajax({
url: adminAjax,
type : "POST",
data: {
action: 'get_my_post',
animal: 'animal',
sport: 'sport',
technologie: 'technologie',
celebrity: 'celebrity'
},
success: function( data ) {
$("#animalpost").html(data);
}
})
this function return a query result from a function in functions.php when i add a condition :
if(is_page("test.php"))
the query ne returned nothing more please help me to fixe that
add_action( 'wp_ajax_get_my_post', 'myfunction' );
add_action( 'wp_ajax_nopriv_get_my_post', 'myfunction' );
function myfunction() {
if ( isset( $_POST['animal'] ))
{
if(is_page( 'test' ) )
{
$args = array( 'post_type' => 'journals'
); $journal = new WP_Query( $args ); if( $journal->have_posts() ):
jQuery.ajax({
url: "<?php echo get_admin_url(); ?>admin-ajax.php",
type : "POST",
data: {
action: 'get_my_post',
animal: 'animal',
sport: 'sport',
technologie: 'technologie',
celebrity: 'celebrity'
},
success: function( data ) {
jQuery("#animalpost").html(data);
}
})
Use this instead of your..hopefully it works :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.