쿼리에서 반환 된 게시물 수를 계산하고 반환 된 게시물을 구문 분석하는 가장 효율적인 방법은 무엇입니까 (시간별)?
는나는 현재이 코드가 :
PART 1
/* $query = {
'numberposts' = '15',
'queryvar1' = '…',
'queryvar2' = '…';
}
*/
$lastposts = get_posts($query); // This uses the original query, and will only return 15 results
$print['returnedcount'] = count($lastposts); // Uses some resources (+ acceptable time)
$query['numberposts'] = "-1"; // Get total results from query
$print['totalposts'] = count(get_posts($query)); // Uses lots of resources (+ lots of time)
나는이 두 번째 get_posts($query)
이 나를 호가 표시 다른 데이터에 대한 아무 소용이 없습니다을, 어떻게 최대 것을 속도를 높일 수 있습니다? 난 단지 numberposts
- 값을 제외하고 쿼리 (에 의해 반환 게시물의 총 수를 계산해야하는
2 부 :.
후 데이터 (ID, 날짜를 얻기 위해 나중에 사용됩니다 -object $lastposts
., 제목, 댓글 수, 썸네일 및 작성자 ID)
이 datas
이$print
에 inputed하는이 맘에 -array : foreach ($lastposts as $post){
// ID
$print['id'][] = (string)$post->ID;
// Date
$print['date'][] = (string)$post->post_date;
// Title
$print['title'][] = (string)$post->post_title;
// Comment count
$print['comments'][] = (string)$post->comment_count;
// Images
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
$print['image'][] = (string)$image[0];
$imageRetina = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
$print['imageretina'][] = (string)$imageRetina[0];
// Author
$print['author'][] = (string)$post->post_author;
}
이 더인가 시간을 효율적으로 사용하는 방법? 나는 이미지 - 행동이 꽤 오랜 시간이 걸리는 것을 알아 챘다. 고마워요!
감사합니다, 나는 시도 할 것입니다 : – Emil
이것은 끝내 었습니다. 고마워요! :) – Emil