나는 WordPress의 내용으로 게시물을 얻으려고하고 있지만, 쿼리와 연결되지 않은 임의의 결과가 나타납니다. 어떤 아이디어?wordpress에서 콘텐츠로 게시물을 얻는 방법
$q='my query';
$query = new WP_Query('s = "'.$q.'"');
$gids = array();
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$gids[]=get_the_ID();
}
} else {
// no posts found
}
wp_reset_postdata();
//
if (count($gids)>0){
//find random one
$rand = array_rand($gids);
$post_id=$gids[$rand];
$post = get_post($post_id);
header('application/json');
echo json_encode($post);
}
같은 것이 http://wordpress.stackexchange.com – DanFromGermany
어쩌면에 속할 수 없지만, 32,472 이상의 워드 프레스 여기에 질문을 태그하고 거기에만 33,293, 그것은 동등하게 될 수있다 그래서 여기에 집에와 마찬가지로 주장했다 – Anigel