You should place your code inside the loop and add to the args
array 'post_id' => get_the_ID()
so it should look like this:
while(have_posts()){
the_post();
//your post loop output
$args = array(
'status' => 'approved',
'number' => '5',
'post_id' => get_the_ID()
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo( $comment->get_avatar . $comment->comment_author . '<br />' . $comment->comment_content);
endforeach;
}
Related Posts:
- Removing Gravatar.com support for WordPress and Simple Local Avatars
- Alternative to using get_avatar function?
- What should I do to make generated avatars different for anonymous comments?
- Using Heroku, need to have non-gravatar avatars, but not stored locally
- How to check if gravatar of user is the default’s one?
- Setting different width and height for gravatar
- Wrong gravatar showing up?
- How to get gravatar url alone
- Replace default avatar
- Listing all users by their avatars in wordpress
- How to output nothing instead of default avatar?
- get the avatar url instead of an html img tag when using get_avatar?
- remove_filter( ‘comment_author’, ‘floated_admin_avatar’ ); doesn’t work
- show author avatar
- Prompt users to Upload Avatar on Registration
- Assign a random avatar to every user?
- Replace comment avatars and links at the same time
- Display avatar of user profile when logged in
- get_avatar() default image not working as of wp 3.5 [closed]
- Cannot get local avatars to show [closed]
- How to restore $args for get_avatar custom “class”?
- How to change avatar of the comment author using comment ID?
- Displaying avatar of a user
- woocommerce allow users to select or use avatar
- Force users to display default Gravatars
- Change wordpress default avatar with custom plugin
- Conditional avatar
- How to get authors avatar
- Which Function Displays The Post Authors Gravatar
- Best way to tell if a comment is from a user?
- How do I accesss gravatar?
- Gravatar – Default IMG
- Custom avatars in wordpress comments?
- How to change users avatar with specific e-mail addresses
- Return WP avatar inside a function
- Hexagon avatar with get_avatar()
- Anyway of specifying avatar height & width?
- Adding avatars/gravatar to a WordPress blog
- How to give users a fixed gallery of avatars to choose from?
- Upload avatar for post comment
- WordPress Custom Local Avatar not showing in comments
- get_avatar_url() how to reset the default image
- Custom Avatars for WordPress Comments VIA Website URL?
- get_avatar() returns image with margin-bottom
- WordPress User Gravatar images not displaying. Loading default instead
- WordPress shows admin’s avatar after editing a comment
- How to have a specific image show up for everyone who comments?
- WP User Avatar preview for users
- Retrieve meta_value from add_comment_meta
- Broken Gravatar images in comments
- get_avatar not working
- How to display user’s avatar on the top of main menu in WordPress admin panel?
- list all authors outside of loop with photo from /uploads
- How can I filter the user avatar displayed in comments? – get_avatar_url filter works everywhere but not in comments
- Is there a way to create multiline comments in Python?
- Is it bad practice to comment out single lines of CSS with //?
- Can comments be used in JSON?
- Can comments be used in JSON?
- How do I comment out a block of tags in XML?
- Is there a way to convert all comments into javadoc comments? [Eclipse/Java]
- How do I comment out a block of tags in XML?
- How do you do block comments in YAML?
- Can comments be used in JSON?
- How do you comment out code in PowerShell?
- Comments in Markdown
- Comments in Markdown
- Visual Studio /**/ comment shortcut?
- How to “comment-out” (add comment) in a batch/cmd?
- Is ‘# -*- coding: utf-8 -*-‘ also a comment in Python?
- How to add comments into a Xaml file in WPF?
- Is it possible to have a multi-line comments in R?
- What is the common header format of Python files?
- How to “comment-out” (add comment) in a batch/cmd?
- Multi-Line Comments in Ruby?
- How to comment and uncomment blocks of code in the Office VBA Editor
- How to write a comment in a Razor view?
- How to write an inline-comment in Python
- R: Comment out block of code
- What’s a quick way to comment/uncomment lines in Vim?
- single line comment in HTML
- Details of difference between @see and @inheritDoc
- Multi-Line Comments in Ruby?
- How to change “Leave a Reply” title in wordpress twentyfifteen theme
- Where can I find the “Leave a Reply” line in the WordPress SmartBiz.1.1.1 theme?
- Show comments on WordPress home page
- Why do I get comment spam even with Akismet and Captcha?
- Is there ANY way to remove comments function and section totally?
- What tools are available for managing/writing to WordPress? [closed]
- How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
- How to rearrange fields in comment_form()
- setting comments off as default for pages and custom post types?
- how to reduce the number of spam comments
- Is it possible to pull comments from facebook into your blog?
- Find out which moderator approved comment?
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How to export comments in WordPress?
- Non-threaded comment replies with link to original comment
- How to make comments work for a post loaded per Ajax?
- Approve comment hook?
- Commenting in user profile page?