Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Check if user has avatar

get_avatar() returns An img element for the user’s avatar or false on failure. The function does not output anything; you have to echo the return value.

so you can try something like that

if( get_avatar( get_the_author_meta( 'ID' ) ) == 0) {
   // no img code
} else {
   echo get_avatar( get_the_author_meta( 'ID' ) , 80 );
}

Related Posts:

  1. Human Time Diff, change mins to minutes
  2. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  3. Force the “Choose from the most used tags” meta box section to always be expanded
  4. Change all author links in Blog roll
  5. saving/reading custom field value does not work – no value gets POSTed
  6. Run function after post is updated
  7. Customize rel=canonical tag for single blog post
  8. How to I retrieve the ID from the Posts page?
  9. How to save meta checkbox WordPress
  10. disable Tab post on nav-menus page (Admin)
  11. Adding bootstrap classes to video shortcodes
  12. How to calculate the average of a post meta value(Numeric) of a specific author
  13. Every second post different class in blog view
  14. Format latest/newest post differently
  15. is_page Funtion for Posts ?
  16. Is there any way to tell when wp_postmeta has been updated?
  17. Post type no single page
  18. Get post meta retrieving wrong value
  19. Adding a user’s ID behind the tag ref link address
  20. wpColorPicker – problem with implementation to post meta
  21. The_excerpt() doesn’t parse – how to change that?
  22. How to only publish posts with image in it
  23. Isn’t the way posts are displayed very unefficient?
  24. Add custom text automatically on each post
  25. How to check in functions.php if there is data in a WP_Query?
  26. Change post author without using wp_update_post()
  27. if in category but only with post meta
  28. restrict incrementation of post vies count when refreshing the page
  29. Defined function isn’t showed on page
  30. wp_query with ajax
  31. Update post meta within save_post action
  32. WordPress 302 Redirect to Random Product/Post/Page
  33. Display post number by category
  34. Updating post meta for checkbox
  35. Saving Post Data in Another Database
  36. Getting Whitescreen when publishing a post [closed]
  37. Using system date format
  38. Get post by tag
  39. Add code to a specific post’s content
  40. Related Posts function not working
  41. Custom permalink for each post
  42. the_content() Not Grabbing All Content
  43. How can I tell if a post has been published at least once?
  44. Un-highlight Blog Menu Item when Category Menu Item is Selected
  45. Is there a way getting post fields using `transition_post_status`
  46. Automatic blog page with custom design [closed]
  47. Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
  48. Add multiple meta keys to a post at once
  49. Show number of posts by logged in user
  50. How does WP decide how to display a page
  51. Related Posts: Changing Function For Posts Per Page
  52. When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
  53. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  54. Query function not executed between element [closed]
  55. Insert data from custom created PHP page into wp_postmeta table
  56. Optimize CPT-function with a loop
  57. Adding a meta box to determine the sidebar [closed]
  58. The loop starting at a certain ID
  59. Simple Custom Metabox Not Saving
  60. Same post appears in related Posts?
  61. Internal linking to posts permalink fail because of spaces and stripe at postname
  62. Get post category as a separate string and url
  63. Have h2 tag not show up if there are no blog posts
  64. WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
  65. Making a wordpress page print friendly
  66. Help on conditional statement to accompany wp_insert_post function please?
  67. How to implement a WordPress comments function?
  68. How to add content above footer in posts from specific category
  69. Set Default Post as Parent Child (Nested) Relation
  70. I need to create “View Profile” and “Edit Profile” links by incorporating the Post Title/ID, but can’t seem to manage it
  71. Featured Images most often doesnt appear
  72. Post meta not working
  73. how to show comments only author which send own posts in wordpress
  74. get category in list of posts // shortcode for custom related posts
  75. shortcode // get posts by ids
  76. How to bulk Update URLs to new values?
  77. Select another post in a post meta like a parent page is selected while editing a page
  78. SQL DELETE multiple post_meta on single and multi-sites
  79. How to put the author of the post in the comments?
  80. Check if almost 10 year old – working code is up to date
  81. Alt text attributes not showing over portfolio images
  82. Find most used words in post titles
  83. WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
  84. $post->post_content empty while all other properties are correct
  85. Function is printing twice – any suggestions?
  86. How to add a custom class attribute into code wrapper? [duplicate]
  87. Private post caught in endless redirect loop
  88. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  89. What is proper filter or hook action to add data to the $post object?
  90. Remove pagination if search returns empty
  91. Remove HTML tags from all posts
  92. Set a post expiration and delete a post when expirate
  93. Blogposting Schema & Structured Data without plugin
  94. Automatically select template based on query string for New Posts
  95. Display Updated Date Instead of Published Date
  96. How do you update post date (year only) in a separate custom field?
  97. I want to change the WordPress comments file
  98. Add postmeta to all blog posts
  99. Replace Tag Keyword With Link Within Post Content
  100. Excluding tag Link from html tags in Post content
Categories posts Tags functions, post-meta, posts
Adding featured image to post display widget
Return customizer setting value in functions.php

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress