저자 목록으로 페이지에 게시물 목록을 원합니다. 저자 게시물은 각 페이지에서 동적으로 사용됩니다. 아래 코드를 사용했습니다.저자에 의한 Wordpress 게시 질의
<ul>
<?php
global $post;
$args = array('posts_per_page' => 3, 'post_type'=> 'post', 'author_name' => 'ppm');
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
저자명 배열을 확인하십시오. ppm 사용자의 게시물을 표시하고 싶습니다. 이제 저는 역동적으로 할 것입니다. 페이지의 사용자 정의 필드에서 저자 이름을 가져오고 싶습니다. Like
<?php $author_name = get_post_meta($post->ID, 'author_name', true); ?>
<ul>
<?php
global $post;
$args = array('posts_per_page' => 3, 'post_type'=> 'post', 'author_name' => '$author_name');
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
그러나 코드가 작동하지 않습니다. 페이지의 사용자 정의 필드에서 작성자 이름을 얻으려면 어떻게합니까? 누구든지 도와 줄 수 있습니까?
약한 영어는 죄송합니다.
'$ post-> ID'를 루프 외부에서 가져올 수 없습니다. – bboy
코드를 참조하십시오 http://wordpress.stackexchange.com/questions/36135/how-can-i-list-posts-by-author 감사합니다, –
나는 루프 안에 시도했지만 여전히 작동하지 않습니다. –