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

Featured image for social sharing ot author archive page

Try copying the following code into your functions.php file.

It adds a custom og:image property for the authors with nicenames of michelle-robinson, mystery-man, john-smith, and a default fallback image, respectively. You can easily change this to suit your needs.

add_action( 'wp_head', 'wpse_70701_author_image' );

function wpse_70701_author_image() {
    if ( is_author( 'michelle-robinson' ) ) {
        // set a custom image if we're visiting Michelle Robinson's author page
       echo '<meta property="og:image" content="http://www.phoneographer.org/wp-content/uploads/link-to-michelle-robinson-image.png" />';
    }
    elseif ( is_author( 'mystery-man' ) ) {
        // set a custom image if we're visiting Mystery Man's author page
       echo '<meta property="og:image" content="http://www.phoneographer.org/wp-content/uploads/link-to-mystery-man-image.png" />';
    }
    elseif ( is_author( 'john-smith' ) ) {
        // set a custom image if we're visiting John Smith's author page
       echo '<meta property="og:image" content="http://www.phoneographer.org/wp-content/uploads/link-to-mystery-man-image.png" />';
    }
    else {
        // set the default fallback image (you may want to omit this section)
       echo '<meta property="og:image" content="http://www.phoneographer.org/wp-content/uploads/link-to-author-image.png" />';
    }
}

Here, I’ve given the function a unique name, but you can call the function anything you want, as long as it is not already the name of another function. If you rename the function, you also need to edit the add_action hook.

Related Posts:

  1. Is there a way to change a post’s thumbnail image(s)?
  2. Get author image from corresponding article in thumbnail
  3. How do I set a featured image (thumbnail) by image URL when using wp_insert_post()?
  4. How do I get image url only on the_post_thumbnail
  5. How to get image title/alt attribute?
  6. How to Fix HTTP Error When Uploading Images?
  7. Add class name to post thumbnail
  8. How to disable WordPress from creating thumbnails?
  9. How to get a buddypress user profile link and a certain user profile field for the current post author?
  10. How to retrieve image from URL and set as featured image/post thumbnail
  11. How to set featured image to custom post from outside programmatically
  12. How do you remove hard coded thumbnail image dimensions?
  13. How do you get the post thumbnail size?
  14. Setting a post’s featured image from an embedded YouTube video
  15. How to get featured image’s width and use elsewhere in template?
  16. set_post_thumbnail_size vs add_image_size
  17. Minimum Dimensions Requirement for Featured Image?
  18. Generate Thumbnails only for Featured Images
  19. How to get all featured image sizes and their URLs?
  20. How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
  21. How to add post featured image to RSS item tag?
  22. How do I regenerate thumbnails?
  23. Display thumbnail only if requested size exists
  24. Delete original image – keep thumbnail?
  25. the_post_thumbnail responsive srcset not populating with custom image size
  26. Set custom name for generated thumbnails
  27. Post thumbnail alt title
  28. Get Featured Image via direct sql query
  29. Get featured image on Blog Index
  30. the_post_thumbnail hard cropping not working no matter what
  31. Can I refresh the thumbnails programmatically?
  32. How to add multiple image sizes of the same size with add_image_size
  33. New image size version only for the Featured Image file
  34. wp_get_attachment_image_src always returns full-sized image
  35. Get featured image URL by page id
  36. change set_post_thumbnail_size according to post type admin page
  37. Add Title Attribute to WordPress Image the_post_thumbnail
  38. Can’t extract and set SVG dimensions
  39. Set Featured Image Front Frontend Form
  40. Getting Thumbnail Path rather than Image Tag
  41. Display Category Thumbnail and links in Woo commerce
  42. the_post_thumbnail with lazyload JQ plugin
  43. Replacing Gutenberg Featured Image control?
  44. Display Post Thumbnail Without Being Featured Image
  45. Featured Image of Video from oembed
  46. oEmbed, thumbnails and wordpress
  47. wp_get_attachment_image_src() and custom sizes
  48. Prevent WordPress from cropping GIF files
  49. media_sideload_image generates blank?
  50. Post thumbnail outside the loop
  51. What’s the difference between post thumbnails and featured images (if any)?
  52. Getting custom-sized featured image’s URL?
  53. What is your take: TimThumb vs. WordPress Thumbnails? The great debate [closed]
  54. How to crop thumbnail height to auto with set width
  55. Retrieve 1st image in post and set it as featured image, when post is saved/updated
  56. Use thumbnail image using url of that image
  57. Retrieve featured image as object
  58. How do I add the featured image to the_content after the first paragraph?
  59. Showing a placeholder/default img, if no featured image is set
  60. Re-order media links?
  61. Multiple featured image thumbnails for post types (Multiple Post Thumbnails plugin)
  62. the_post_thumbnail scaling not hard cropping
  63. Skip posts without a thumbnail in loop
  64. wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); Getting thumb from wrong loop
  65. Set featured image for multiple posts
  66. Image uploader with “Set Featured Image” link on front end
  67. adding an id to the_post_thumbnail
  68. Featured image size in ADMIN panel?
  69. Featured image with the same height thumbs returns wrong thumb
  70. How can I display my featured image correctly inside my single posts?
  71. How to change the naming of the resized image files
  72. Featured image upload finished hook
  73. How to get featured post title & image using JSON API?
  74. Generate thumbnail for images with the same size as thumbnails
  75. Set post thumbnail as background
  76. Display thumbnail only on the very first post in the loop?
  77. How to show featured image CAPTION only if it exist
  78. Set post-thumbnail (with php)?
  79. get_thumbnail_id returns full size image
  80. Implementing Zurb’s Interchange Into WordPress
  81. can the_excerpt function also get images?
  82. If Else Gravatar Author Picture
  83. How to get_posts having post thumbnail?
  84. Add Image Dimensions to Media Library Tab on Media Upoader
  85. Change Output for Images in Content
  86. Featured Image Inherited from Parent Page
  87. Change wording of default thumbnail metabox
  88. Specific featured image for each category
  89. how to pull images with no add_theme_support(‘post_thumbnails’)
  90. Can WordPress crop only the post thumbnails?
  91. Allow user to manually set crop area of default/custom image sizes on upload [closed]
  92. Add post title as alt tag for featured image
  93. get_pages – Display child then grandchild pages
  94. How to replace the_post_thumbnail template tag and show the first inside the post image instead
  95. Display child pages on a parent and child page using Featured Thumbnails
  96. Query the post which have a thumbnail
  97. Featured image for news page
  98. How to get the image sizes, in a function, as per the sizes mentioned in the media settings?
  99. How to scale up image into thumbnail without distorting it?
  100. Using Gutenberg block components in admin interface controls
Categories post-thumbnails Tags author, post-thumbnails, social-sharing, user-meta
How can I re-register my blogs widgets?
wpdb inside foreach loop only returns first result – 2 other similar cases found [closed]

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