FEATURE Handling main authors in additions to author in buil posts query
This commit is contained in:
parent
7f6be681fe
commit
f06fe21a5a
|
|
@ -13,7 +13,6 @@ add_action('rest_api_init', function () {
|
||||||
'callback' => 'build_posts',
|
'callback' => 'build_posts',
|
||||||
'permission_callback' => '__return_true',
|
'permission_callback' => '__return_true',
|
||||||
));
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,14 +72,20 @@ function build_posts($request)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtre par auteur
|
// Filtre par auteur (authors = relation multiple, main_author = auteur principal)
|
||||||
if (!empty($auteur) && $auteur != '1') {
|
if (!empty($auteur) && $auteur != '1') {
|
||||||
$args['meta_query'] = array(
|
$args['meta_query'] = array(
|
||||||
|
'relation' => 'OR',
|
||||||
array(
|
array(
|
||||||
'key' => 'authors', // Ajustez selon votre structure
|
'key' => 'authors',
|
||||||
|
'value' => '"' . $auteur . '"',
|
||||||
|
'compare' => 'LIKE',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => 'main_author',
|
||||||
'value' => $auteur,
|
'value' => $auteur,
|
||||||
'compare' => 'LIKE'
|
'compare' => 'LIKE',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +101,7 @@ function build_posts($request)
|
||||||
ob_start();
|
ob_start();
|
||||||
if ($posts_query->have_posts()) :
|
if ($posts_query->have_posts()) :
|
||||||
while ($posts_query->have_posts()) : $posts_query->the_post();
|
while ($posts_query->have_posts()) : $posts_query->the_post();
|
||||||
get_template_part('template-parts/components/cards/post-card', null, array(
|
get_template_part('template-parts/components/cards/post-card', null, array(
|
||||||
'ID' => get_the_ID(),
|
'ID' => get_the_ID(),
|
||||||
));
|
));
|
||||||
endwhile;
|
endwhile;
|
||||||
|
|
@ -118,4 +123,3 @@ function build_posts($request)
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user