Wordpress - 작성자 이미지 가져오기
<?php while ( have_posts() ) : the_post(); ?>
<section class="panel panel-white">
<div class="row single-post-content">
<?php if ($category_name !== 'Jobs') { ?>
<h5 class="author-post__title"><?php the_author() ?></h5>
<p><?php echo get_the_date(); ?></p>
<?php }
the_content();
if ($category_name !== 'Jobs') { ?>
<div class="row author-post">
<div class="small-12 medium-4 column">
<img src="<?php echo get_avatar(); ?>" alt="" />
</div>
<div class="small-12 medium-8 column">
<h5 class="author-post__title"><?php the_author() ?></h5>
<p>
Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s
with the release of Letraset sheets containing.
</p>
</div>
</div>
<?php } ?>
</div>
</section>
<?php endwhile;?>
나는 투고를 쓴 작가의 아바타를 조사하려고 한다.그렇게 하면 될 줄 알았는데 URL이 제대로 출력되지 않아 이미지에 404가 나옵니다.
다른 사람들은 아바타 이미지를 끌어내기 위해 어떤 방법을 사용했습니까?
어떻게 해야 하는지, 안 보여줘야 할 이미지가 없는지를 알려주는 답을 찾고 있습니다.
갱신:
아래 코드를 사용하여 작업을 수행하려고 했습니다.로컬 머신에서도 이 작업을 수행할 수 있도록 노력하고 있습니다.
echo get_avatar($authorId, 100);
(변수는get_the_author_id()
)
<?php echo get_avatar( $id_or_email, $size, $default, $alt, $args ); ?>
어디에id_or_email
필수 항목입니다.코드에는 이것이 없습니다.자세한 것은, https://codex.wordpress.org/Function_Reference/get_avatar 를 참조해 주세요.
따라서 코드로 작성자 이미지를 가져옵니다.
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>
적절한 아바타를 가져오려면 "id_or_email"에 대한 매개 변수를 추가해야 합니다.WordPress 2.7 이하의 경우 get_the_author_id()를 사용할 수 있습니다.WordPress 2.8 이상에서는 get_the_author_meta('ID')를 사용할 수 있습니다.함수는 문자열 또는 거짓 부울 중 하나를 반환합니다.반환된 값을 비교하여 아바타가 있는지 여부를 확인할 수 있습니다. - get_avatar
<?php while(have_posts()): ?>
<?php the_post(); ?>
<section class="panel panel-white">
<div class="row single-post-content">
<?php if($category_name !== 'Jobs'): ?>
<h5 class="author-post__title">
<?php the_author() ?>
</h5>
<p><?php echo get_the_date(); ?></p>
<?php the_content(); ?>
<div class="row author-post">
<div class="small-12 medium-4 column">
<?php if($avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
<img src="<?php echo $avatar; ?>" alt="">
<?php else: ?>
<img src="/images/no-image-default.jpg">
<?php endif; ?>
</div>
<div class="small-12 medium-8 column">
<h5 class="author-post__title"><?php the_author() ?></h5>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing.</p>
</div>
</div>
<?php else: ?>
<?php the_content(); ?>
<?php endif; ?>
</div>
</section>
<?php endwhile; ?>
언급URL : https://stackoverflow.com/questions/40751664/wordpress-get-author-image
'programing' 카테고리의 다른 글
reactj의 인라인 스타일에 벤더 프리픽스를 적용하려면 어떻게 해야 하나요? (0) | 2023.03.20 |
---|---|
ReactJS: onClick 핸들러를 자 컴포넌트에 배치해도 부팅되지 않음 (0) | 2023.03.20 |
클래스 컴포넌트에서 React.useRef()를 사용하는 방법 (0) | 2023.03.20 |
스프링 캐시 Java에서 여러 캐시 매니저 구성을 사용하는 방법 (0) | 2023.03.20 |
NSJON Serialization 오류 - JSON 쓰기(메뉴)에 잘못된 유형이 있습니다. (0) | 2023.03.20 |