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

Facebook social publisher and custom post type fields [closed]

reading the code of the Facebook Official Plugin I’ve seen that in

open-graph-protocol.php

It’s being applied the custom filter ‘fb_meta_tags’:

..
$meta_tags = apply_filters( 'fb_meta_tags', $meta_tags, $post );
..

So in my plugin I’ve added a filter for ‘fb_meta_tags’ that adds/replace the image set from the Facebook plugin in this way:

function clancat_product_fbmeta($meta_tags, $post){
    ..
    $img = get_post(get_post_meta($post->ID, 'immagine', true)); 
    $meta_tags['http://ogp.me/ns#image'] = $img->guid;
    ..
    return $meta_tags;
}

..

add_filter( 'fb_meta_tags', 'clancat_product_fbmeta',10,2);

Please note that the “2” (4th param passed to add_filter) is mandatory, because the Facebook filter it’s providing the $meta_tags array and the $post object.

I think this solution ca be easily extended to any post-type / custom-field etc. situation; and that’s the correct way to achieve this goal.

Unfortunately this not solve the publish problem.

Related Posts:

  1. What’s the most efficient way to get two queries based on an if statement?
  2. Attach several custom posts to one meta field
  3. Custom Field to post_title
  4. Automatically convert standard posts with custom fields to custom post types
  5. Custom Fields through plugin in a Custom Post Type
  6. WordPress query in which condition uses custom field
  7. WordPress loop add heading before first of type
  8. How do i create user accounts from custom posts that have email addresses
  9. Importing URLs of Audio Enclosures
  10. How to make a shortcode for my WP_Query Loop? [duplicate]
  11. Multiple domains, Single database, 1 Parent/Master with all content, other domains/slaves with filtered content (based on “location” variable)
  12. WordPress is giving a warning but my code is working fine
  13. Error in WP Query. If variable is empty it is displaying previous post value
  14. WordPress loop, show only one post per custom field
  15. Query events post type after current date and timezone
  16. How to display all custom fields associated with a post type – IN THE ADMIN AREA?
  17. Avoid another meta box in my custom post type
  18. Show first posts with custom field not empty and order all by title
  19. Can’t pick up a field created with Advanced Custom Fields
  20. Need some suggestion/help with custom post types project
  21. Best way to use Category & Custom Fields?
  22. Pre_get_posts comparison with custom field doesn’t work
  23. Delete custom post type metadata without deleting the post in admin area
  24. Retrieving custom post type fields without a post
  25. Best way to insert a js script in the header with custom fields and CPT
  26. Creating connections programmatically with common fields on CPT’s
  27. Amend posts using wp_insert_post
  28. Custom Fields as Post Type Options
  29. How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
  30. How to delete comma from the end of results? [closed]
  31. How to use TOC with ACF?
  32. Publish post and create additional posts with same content
  33. How to enable the user to add value through the admin panel?
  34. Get month and day from a Date Picker custom field
  35. Two plugins sharing the same custom post type registration
  36. custom fields not showing before get_header
  37. Creating multiple CPT posts from one Gravity form
  38. How to add post reference field to a plugin?
  39. Generate slug and meta data if meta field is empty
  40. pre_get_posts with multiple post types AND a meta_key
  41. Search form to find custom meta box generated data
  42. Calling specific page with wp query
  43. Custom Info Box at end of posts?
  44. How to get past and upcoming post by defining date in custom field?
  45. How to stop wp_query searching pages as well as the specified CPT
  46. Converting a checkbox filter for custom fields to a dropdown
  47. Post content is cleared when updating
  48. How do I add custom fields to posts without having to manually add everytime I post?
  49. Function not pulling image or text from custom post type
  50. Display Custom Post if custom field is marked
  51. Default custom column to off
  52. predefined custom field on registration page
  53. How to display custom post type ordered by a custom field date
  54. Selecting posts older than the current Unix epoch timestamp
  55. Unable to get the upcoming events for custom post
  56. Order Custom Posts by Several Fields
  57. one get_posts to return a number of custom posts for each meta value
  58. Show Custom Post Type taxonomy term that matches custom field
  59. display some fields in custom post backend
  60. Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
  61. Query Distinct Taxonomies of Custom Post Type
  62. Custom Post Type as invoice or order template
  63. Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
  64. Custom field totals
  65. custom taxonomies are not showing up in get_taxonomies
  66. WP_Query and two custom fields returns no posts
  67. Forms with multiple element types using custom post types
  68. Displaying database table in backend of wordpress
  69. WP_Query get posts where post_name is empty
  70. Is it good practice to search for custom posts based on custom field values?
  71. Custom post type with custom fields enabled, is there a way to set a default group of fileds?
  72. Storing/querying custom date data
  73. Custom post type won’t take my custom fields
  74. Order by custom field attribute
  75. Get result from Custom Field in Custom Post type
  76. If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
  77. Make each Value of custom field show related posts when clicked
  78. How to display Multi Checkbos select Custom Field on the post?
  79. I want to split this into two functions
  80. custom field suit new post with in custom fields
  81. Repeatable Custom Field for Media Upload
  82. Show a custom field instead of username in the backend author area
  83. Filter CPT based on meta box value using Flexible Posts widget?
  84. Echo custom field value
  85. Select Menu for Custom post Type does not save
  86. Customizing the display of custom post types
  87. Repeatable custom meta select boxes
  88. Create shortcode for list of custom post titles with custom fields alongside
  89. Display custom posts in checkbox list
  90. Display posts order by custom post in a dropdown menu
  91. Advanced search form with filters for custom taxonomies and custom fields
  92. Query recent posts by author
  93. 404 on Pages for Custom Post Type & Query_Posts
  94. Custom post type and custom taxonomy archive inaccessible
  95. How to insert post into a page?
  96. Textarea type on one field custom add_meta_box?
  97. How to show animal lineage/pedigree in WordPress?
  98. How can i display on front page a movie that is atached in a post type
  99. WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
  100. Rewriting a page driven by custom fields to populate a page dynamically, like posts
Categories custom-post-types Tags custom-field, custom-post-types, facebook, open-graph, social-sharing
style.css not reflecting changes. I have no cache installed
Incorrect redirection after commenting on custom type

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