0
플러그인을 개발 중입니다. 이 플러그인에서 커스텀 포스트 타입 'toto'를 만들었습니다.Wordpress, 쿼리 후 글로벌 게시물이 변경됨
관리 페이지에서 다음 게시물 ID가 '82'인 맞춤 게시물 요소를 수정합니다. 이 페이지에서 , 나는 그와 같은 다른 post_type와 요소를 검색하는 쿼리를 실행 :
$featured_args = array(
'post_type' => 'other_type',
'post_status' => 'publish'
);
// The Featured Posts query.
$featured = new WP_Query($featured_args);
// Proceed only if published posts with thumbnails exist
if ($featured->have_posts()) {
while ($featured->have_posts()) {
$featured->the_post();
if (has_post_thumbnail($featured->post->ID)) {
/// do stuff here
}
}
// Reset the post data
wp_reset_postdata();
}
글로벌 $ 포스트의 변경을 수행. ID 82를 가진 게시물이 아니라 쿼리의 최신 게시물 요소입니다.
wp_reset_postdata() 함수를 사용하면 현재 $ post를 검색 할 수 있다고 생각했습니다. wp_reset_query()를 변경하지 않고 시도했다. 내가 빠진 것이 있습니까?
도움을 주시면 감사하겠습니다.
제가 생각했던 대안이었습니다. 감사 맥스. 나는이 해결책을 사용할 것이다. – titchagcreation