Ajouter une fonction a function.php

Fermé
Houssine@ Messages postés 37 Date d'inscription jeudi 2 juin 2016 Statut Membre Dernière intervention 3 janvier 2019 - 2 janv. 2019 à 22:43
Houssine@ Messages postés 37 Date d'inscription jeudi 2 juin 2016 Statut Membre Dernière intervention 3 janvier 2019 - 3 janv. 2019 à 01:41
Bonjour,
j'ai un fichier page-animal.php et script.js et functions.php.
J'ai ajouté une fonction ajax a mon script qui retourne une requête de tous les animaux et quand j'ai voulu ajouté une condition de if(is_page(page-story)) la requête ne retourne plus rien comment procéder pour ajouter cette fonction et merci d'avance


Configuration: Windows / Chrome 71.0.3578.98
A voir également:

1 réponse

Houssine@ Messages postés 37 Date d'inscription jeudi 2 juin 2016 Statut Membre Dernière intervention 3 janvier 2019
Modifié le 3 janv. 2019 à 01:42
-3


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() ):
0