반응형
미디어 파일 워드프레스를 모두 받을 수 있는 기능은 무엇입니까?
워드프레스용 이미지를 모두 저장할 수 있는 기능이 무엇인지 제안해 주실 수 있습니까?Wordpress admin의 Media 메뉴에 표시되는 모든 이미지를 나열하기만 하면 됩니다.
잘 부탁드립니다
업로드된 이미지는 "attachment" 유형의 게시물로 저장됩니다. 올바른 매개 변수와 함께 get_posts()를 사용하십시오.get_posts()의 Codex 엔트리에서 다음 예를 나타냅니다.
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
the_excerpt();
}
}
?>
...모든 첨부 파일을 검토하여 표시합니다.
TheDeadMedic의 코멘트대로, 이미지를 취득하고 싶은 경우는, 다음의 방법으로 필터링 할 수 있습니다.'post_mime_type' => 'image'
의론에서.
<ul>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li>';
echo wp_get_attachment_image( $attachment->ID, 'full' );
echo '<p>';
echo apply_filters( 'the_title', $attachment->post_title );
echo '</p></li>';
}
}
endwhile; endif; ?>
</ul>
언급URL : https://stackoverflow.com/questions/3307576/what-is-the-function-got-get-all-the-media-files-wordpress
반응형
'programing' 카테고리의 다른 글
Wordpress permalink '이 서버에서 찾을 수 없습니다' (0) | 2023.03.23 |
---|---|
속성에 따옴표 없이 JSON.stringify를 지정하시겠습니까? (0) | 2023.03.23 |
보기에서 응용프로그램/json MIME 유형 강제 적용(플래스크) (0) | 2023.03.23 |
jQuery JSON 응답은 항상 ParseError를 트리거합니다. (0) | 2023.03.23 |
표의 모든 행을 효율적으로 업데이트하는 방법 (0) | 2023.03.23 |