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

Adding Facebook’s image and meta description retrieval capabilities to a WordPress post

I believe Facebook uses the Open Graph protocol for this. Basically, a site that provides certain Open Graph meta tags can have the data that these tags refer to appear nicely formatted on Facebook.

Example from the Open Graph protocol site:

<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

You could probably use a similar approach if this suits your use case.

For sites without these tags, Facebook does indicate that:

Without these tags, the Facebook Crawler uses internal heuristics to make a best guess about the title, description, and preview image for your content.

If your question is centered around how this can be achieved, things might get a little more complicated. You could try an approach in which, based on a WordPress post URL, you perform a GET request on the associated blog’s REST API that fetches the metadata of that particular post for you.

Related Posts:

  1. Display info from custom fields in all images’ HTML
  2. copy attachments to another post type and change attachment url
  3. How to add the image URL from an external RSS feed and insert into a custom field?
  4. How to get custom image field of specific post id
  5. Can I exclude a post by meta key using pre_get_posts function?
  6. Custom post meta field effect on the performance on the post
  7. How to get custom post meta using REST API
  8. Difference between meta keys with _ and without _ [duplicate]
  9. Remove Dimension from wp_get_attachment_image
  10. Orderby meta_value only returns posts that have existing meta_key
  11. What is the index [0] for on post meta fields?
  12. What is “meta_input” parameter in wp_insert_post() used for?
  13. How to enable revisions for post meta data?
  14. The “_encloseme” Meta-Key Conundrum
  15. Best way to programmatically remove a category/term from a post
  16. Using get_post_meta with new_to_publish
  17. Custom field metabox not showing in back-end
  18. So much data in postmeta
  19. Can I count the number of users matching a value in a multiple value key?
  20. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  21. How to hide meta box values from custom fields list?
  22. Auto sort the wp-admin post list by a meta key
  23. Change wp_get_attachment_image attributes (src and srcset) on specific custom field
  24. How do I make a custom field choose an image?
  25. get_post_meta() unserialize issue – returns boolean(false)
  26. What is the advantage of the wp_options design pattern?
  27. Storing meta fields multiple times OR once with multi dimensional array?
  28. Allow user to create instances of custom field
  29. display specific custom fields
  30. Extend WP Customizer to make multiple image selection possible
  31. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  32. Add multiple images to a page sidebar
  33. Meta keywords and descriptions plugin for manually editing meta for each page/post
  34. passing argument to get_template_part() or a better way to code
  35. Is it possible to store arrays in a custom field?
  36. Get updated meta data after save_post hook
  37. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  38. Save HTML formatted data to post meta using add_post_meta()
  39. importing data from non-wordpress mysql db
  40. Display thumbnail from custom field
  41. Add custom field to image editor
  42. Create meta boxes that don’t show in custom fields
  43. Transients vs CRON +Custom Fields: Caching Data Per Post
  44. Unable to save datetime custom meta field using update_post_meta() function
  45. Up/Down voting system for WordPress
  46. post meta data clearing on autosave
  47. Create custom field on post draft or publish?
  48. Ordering posts by anniversary using only day and month
  49. How to get source of custom meta image?
  50. get_post_meta fields don’t show up on posts page
  51. Update meta values with AJAX
  52. How to break meta values into different items and avoid duplicates?
  53. automatically set “Featured Image” the same as the og:i that is set in a custom field
  54. Cannot edit post meta fields with rest API
  55. limit amount of photos uploaded per cpt post
  56. ajax delete value from custom field array
  57. Save attachment custom fields on front end
  58. How to use pagination with get_post_meta
  59. Copying Custom Meta Values from existing post to a duplicate post
  60. Add a post meta key and value only if it does not exist on the post
  61. Move value of one custom field to another
  62. Order posts according to user defined order for meta values?
  63. Displaying posts with only upcoming dates according their custom field date value
  64. Custom fields to save multiple values
  65. Custom fields: In what order are they saved into the DB?
  66. Function to change meta value in database for each post
  67. Get a post_id where meta_value equals something in a serialized meta_value field
  68. Metabox with multiple fields added by user and upload box
  69. Get aggregate list of all custom fields for entire blog
  70. Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
  71. Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
  72. Custom field value based on other custom field values
  73. wp_handle_upload error “Specified file failed upload test” but still creates attachment?
  74. How to save a ToggleControl value in a meta field?
  75. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  76. Add WYSIWYG to Image Description field
  77. Saving custom image meta fields
  78. Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
  79. How to display Meta Field Value?
  80. MySQL query to set wp_postmeta using term_taxonomy_id value
  81. How to Validate Post Meta type/extension (Video File Image File etc)
  82. Get all meta keys assigned to a post type
  83. Get Meta from Custom Field of Image URL
  84. Add url from Custom Field as ‘Featured Image’. Code not working
  85. Add source URL from Feed WordPress (Syndication) plugin to a custom field in post editor
  86. using multiple meta_key and meta_value in query_posts
  87. Custom Meta Box not Saving in Posts with Gutenberg Editor
  88. Adding custom fields (post meta) before/during wp_insert_post()
  89. Combine multiple custom field values into single value
  90. How can I sort homepage by a meta value?
  91. Get specific custom field keys from a post and put into an array
  92. List all images from a single post meta value
  93. How do I use wp_query for WordPress search?
  94. Nav Menu – Add class based on meta keys
  95. How to query posts with certain custom meta data, and output Post data
  96. MySQL Query that looks for post with Custom Field, then changes Category
  97. ACF: How to get the full field name (meta_key) by a field key?
  98. How to wrap meta values seperated by comma in ? [closed]
  99. Bulk remove post meta
  100. post meta getting deleted on save
Categories custom-field Tags custom-field, images, post-meta, urls
Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
Show category in Previous/Next links

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