The function get_the_author_meta('ID')
will return the ID of the author for the current post.
That means this line should work.
get_avatar( get_the_author_meta( 'ID' ), 120);
This will not work
get_avatar( get_the_author_meta( '4' ), 120);
Because you are trying to get a property named ‘4’ inside the user object and that property doesn’t exist.
If you wanted to get the avatar for user 4 you would use.
get_avatar( 4, 120);
Because get_avatar takes either a $user_id
or $email
as the first parameter and the $size
as the second.
On a final note the WordPress documentation uses, so check for a formatting error in your html.
get_avatar( get_the_author_meta( 'ID' ), 32 );
Related Posts:
- Can’t access PHP array inside script localization from javascript
- How to get user ID’s from multiple usernames?
- using update_user_meta to rank users
- How to get all multi-select user meta values and add them to an array?
- Exclude Posts Using Meta Query and User Meta
- Display all existing members
- Retrieve each widget separately from a sidebar
- Should I use loop in the single.php file?
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- Where should I use post_class()?
- Landing Page – Redirect Loop?
- How to make multiple Column in archive Page?
- Sort Popular Posts by Views for the Last Week
- get_the_foo() in the loop – does it perform another query?
- Exclude filter on front page
- Is it possible to display previous post revision?
- Check if date of post is yesterday
- Exclude first 2 posts with meta_key from loop
- Fix inefficient loop breaks post.php on form submit
- Make a custom loop inside single.php with pagination
- Why do I get `Call to a member function have_posts() on a non-object `? [closed]
- Adding shortcode closing tag after a loop
- Get Pagination (WP-PageNavi) not to work
- Filtering The Loop For Single Page and Blog Page
- the_content() seems to block my ACF-code
- Pulling current post/page data into header.php
- Removing the_content() from the page
- Loop and Page template : my WP_query don’t take args
- How to split a loop into two columns
- Transient loop issue
- Filter the loop by categories using checkbox form
- Get single post from tags array
- Duplicated posts on category page
- WordPress loop: exclude if it is the latest post
- Apply an Incremental Counter in an Array Function
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- query_posts() vs get_posts() multiple loops [duplicate]
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- Latest Post Styled Different Than other Posts
- How do I make a variable available inside partials?
- WordPress: Loop Help
- Woocommerce: How to display product price [closed]
- Display Post Author Link above the loop
- Enabling users to control custom loop’s query
- How to get the excerpt for is_home() outside of the loop isn’t working
- Make loop alphabetical
- How to check if a product is purchased within the last 365 days before displaying something
- How do I get my loop.php to properly paginate?
- Category links including all posts
- Custom loop ordering not working
- First archive page with a few posts
- Hiding a row in the loop if empty
- Loop through ACF taxonomies and output associated posts
- Query posts only with actual text content (not including shortcode or images)
- CPT while loop not working
- How can this multiple loop have pagination as described?
- Default featured image set as background image [closed]
- Breaking up the results of a loop
- Where to add offset?
- How do i create a list-posts-page?
- Exclude posts based on an array
- Is file_exists() compatible with timthumb.php? [closed]
- List ALL posts by author on author archive
- Using is_page_template inside loop
- Set depth of pages to fetch
- Trying to get all links in my posts
- Creating a User-Adjustable chart in WordPress
- Archive: Lists itself
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Reorder posts in a loop: have the posts by one particular author below the others
- Slug is changing when I use WP_Query in a metabox of a post
- How to execute a user loop with shortcode
- how to get author comment inside the loop?
- How to create loop in custom page, and get id from url into this loop?
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Archive sorted by month – separate
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- Building theme so user can change header image [closed]
- Get query result before posts are displayed?
- WordPress Group By Problem
- using the loop on a page
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- Eliminate duplicates in a foreach loop [closed]
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- Display all posts in a page code for template
- How can you make it so the comment box shows on some pages or posts but not all?
- Use Base-URL with Query-Loop