반응형
WordPress에서 모든 게시물을 표시하는 방법
내 WordPress 홈 페이지에 모든 게시물을 표시하려고 합니다.
나는 모든 우편물을 받기 위한 다음 질문을 썼지만 모든 우편물을 받지 못했다.10개 또는 11개의 투고만 표시됩니다.
$args = array(
'post_type' => 'post',
'posts_per_page' => $number,
'order' => $sort_by,
'orderby' => 'title',
'post_status' => 'publish',
'tag' => $tags,
'ignore_sticky_posts' => 1,
);
$args['tax_query'] = array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-video',
));
$query = new WP_Query($args);
그래서 어떻게 하면 모든 포스트를 받을 수 있는지 알려주세요.
게시된 모든 게시물을 표시합니다.모든 게시물을 검색하려면 post_per_page='-1'을 사용해야 합니다.
$args = array(
'post_type'=> 'post',
'orderby' => 'ID',
'post_status' => 'publish',
'order' => 'DESC',
'posts_per_page' => -1 // this will retrive all the post that is published
);
$result = new WP_Query( $args );
if ( $result-> have_posts() ) : ?>
<?php while ( $result->have_posts() ) : $result->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
기대한 대로 모든 게시물이 검색되기를 바랍니다.
여러 루프를 시도합니다.
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- do stuff ... -->
<?php endwhile; ?>
<?php endif; ?>
Advanced 쿼리가 필요한 경우 다음을 사용합니다.
<?php query_posts( 'post_type=post&posts_per_page=10'); ?>
query_parts()를 사용하여 모든 게시물을 가져올 수 있습니다.
변수 설정posts_per_page => -1
따라서:
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'order' => $sort_by,
'orderby' => 'title',
'post_status' => 'publish',
'tag' => $tags,
'ignore_sticky_posts' => 1,
);
그러면 쿼리가 테이블 내의 모든 게시물을 가져옵니다.
언급URL : https://stackoverflow.com/questions/39047664/how-to-display-all-posts-in-wordpress
반응형
'programing' 카테고리의 다른 글
| WordPress "wp_register_style이 잘못 호출되었습니다?" (0) | 2023.03.14 |
|---|---|
| my.cnf에 대한 Mysqltuner 제안 및 변경 사항 (0) | 2023.03.14 |
| 미발견 오류: 예상보다 적은 수의 후크가 렌더링되었습니다.리액트 훅의 우발적인 조기 반환 문구가 원인일 수 있습니다. (0) | 2023.03.14 |
| 무한 스크롤 수동 트리거 (0) | 2023.03.14 |
| 각도가 있는 옵션 선택에서 공백 옵션 제거JS (0) | 2023.03.14 |