admin管理员组文章数量:1130349
how can U get latest posts from a specific category and post them with the picture of the author. All authors are signed as an author on WordPress and they all have profile picture. Actually it will stand for columns side like this and the system must get latest 1 first then the second and third goes like this...
how can U get latest posts from a specific category and post them with the picture of the author. All authors are signed as an author on WordPress and they all have profile picture. Actually it will stand for columns side like this and the system must get latest 1 first then the second and third goes like this...
Share Improve this question edited Nov 10, 2018 at 19:52 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 10, 2018 at 13:38 buğracanbuğracan 251 silver badge8 bronze badges1 Answer
Reset to default 0You could try something like this:
<?php
$args = array( 'category' => 12, 'post_type' => 'post' );
$postslist = get_posts( $args );
foreach ($postslist as $post) :
setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<h4><?php the_author();?></h4>
<?php
the_excerpt();
echo get_avatar(get_the_author_meta());
endforeach;
?>
In the example the category id is set to 12 - just replace it with the id of the category you want to use.
More info:
How to loop through posts: https://developer.wordpress/reference/functions/get_posts/#user-contributed-notes
How to get the author name: https://codex.wordpress/Function_Reference/the_author
How to get the author image: https://codex.wordpress/Function_Reference/get_avatar
how can U get latest posts from a specific category and post them with the picture of the author. All authors are signed as an author on WordPress and they all have profile picture. Actually it will stand for columns side like this and the system must get latest 1 first then the second and third goes like this...
how can U get latest posts from a specific category and post them with the picture of the author. All authors are signed as an author on WordPress and they all have profile picture. Actually it will stand for columns side like this and the system must get latest 1 first then the second and third goes like this...
Share Improve this question edited Nov 10, 2018 at 19:52 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 10, 2018 at 13:38 buğracanbuğracan 251 silver badge8 bronze badges1 Answer
Reset to default 0You could try something like this:
<?php
$args = array( 'category' => 12, 'post_type' => 'post' );
$postslist = get_posts( $args );
foreach ($postslist as $post) :
setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<h4><?php the_author();?></h4>
<?php
the_excerpt();
echo get_avatar(get_the_author_meta());
endforeach;
?>
In the example the category id is set to 12 - just replace it with the id of the category you want to use.
More info:
How to loop through posts: https://developer.wordpress/reference/functions/get_posts/#user-contributed-notes
How to get the author name: https://codex.wordpress/Function_Reference/the_author
How to get the author image: https://codex.wordpress/Function_Reference/get_avatar
本文标签: theme developmentHow to display latest posts with authors image
版权声明:本文标题:theme development - How to display latest posts with authors image 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749181890a2328748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论