반응형
특정 템플릿이 있는 워드프레스 쿼리 페이지
특정 템플릿이 있는 Wordpress 페이지를 조회하는 방법이 있습니까?여기 내가 얻은 게 있는데 아무것도 안 보여:
<?php $my_query = new WP_Query(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'template-city.php' )); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li>
<?php the_title(); ?>
</li>
<?php endwhile; ?>
물론 페이지 템플릿 파일 이름이 있습니다.template-city.php
한다면post_typeWP가 투고를 찾고 당신은 페이지를 찾고 있습니다.
<?php
$args = array(
'post_type' => 'page',//it is a Page right?
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => 'template-city.php', // template name as stored in the dB
)
)
);
$my_query = new WP_Query($args)
?>
언급URL : https://stackoverflow.com/questions/12086998/wordpress-query-pages-with-certain-template
반응형
'programing' 카테고리의 다른 글
| Oracle에서 특정 테이블이 언제 생성되었는지 확인하는 방법 (0) | 2023.03.05 |
|---|---|
| react-router-dom 속성 'sumParams'에서 버전 4 useParams()를 업그레이드한 후 TypeScript 오류가 '{}' 유형에 없음 (0) | 2023.03.05 |
| $dirty 형식의 리셋 방법 (0) | 2023.03.05 |
| 새 사이트가 생성되었지만 내 사이트 드롭다운에 표시되지 않음 (0) | 2023.03.05 |
| Angular에 지연을 적용하는 방법JS (0) | 2023.03.05 |