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

Modify WP_Post before processing

There is a the_post hook which should let you modify the post object:

function my_the_post_action( $post_object ) {
    // modify post object here
}
add_action( 'the_post', 'my_the_post_action' );

But the post data isn’t where your thumbnails are stored. They are associated via a post meta field. That is what you are going to have to manipulate. Something like:

function my_thumbs($n, $object_id, $meta_key, $single ) {
  if ('_thumbnail_id' == $meta_key) {
    echo 'image link';
  }
}
add_filter( "get_post_metadata", 'my_thumbs', 10, 4 );

Though I have no idea how complex that function would need to be.

Honestly, if you are running WP 2-something you need to update and spend the time converting your improvised system to Core functions. Sincerely.

Related Posts:

  1. Custom excerpt length filter doesn’t work
  2. How to generate numbers indistinguishable for the IDs of the posts
  3. Hook for changing excerpt content when excerpt not set
  4. Filter question list on substring of metavalue
  5. How enter custom post meta or custom field on box post list archive page?
  6. How to automate featured posts number? [duplicate]
  7. How to check if single.php has already called the_post_thumbnail function
  8. add to end of post in the loop with plugin
  9. Getting only the URL of the post thumbnail
  10. Add filter to the end of the post
  11. Remove Featured Image & All Media Uploaded to the Post
  12. Get post content with all filters applied, knowing post id
  13. Get Post’s first image using Short-code
  14. Customize rel=canonical tag for single blog post
  15. Change all author links in Blog roll
  16. How to I retrieve the ID from the Posts page?
  17. How to save meta checkbox WordPress
  18. Adding bootstrap classes to video shortcodes
  19. related author post thumbnail shows post thumbnail
  20. Is it possible to filter the main loop to exclude posts from a specific category?
  21. How to calculate the average of a post meta value(Numeric) of a specific author
  22. query post limits
  23. Is there any way to tell when wp_postmeta has been updated?
  24. Admin – no Featured image choice in create new/page|post
  25. Displaying post excerpt using wpdb query
  26. Post Image not displaying in category view
  27. preg_replace not removed “class”
  28. wpColorPicker – problem with implementation to post meta
  29. How to disable the_excerpt from one post
  30. The_excerpt() doesn’t parse – how to change that?
  31. Trying to edit archive.php to only show post extract, with featured image
  32. Modify posts listing at back end
  33. Filtering posts on Post Administration Page by Week Number instead of by Month
  34. Prevent posts with certain post_meta to be edited
  35. Change post author without using wp_update_post()
  36. Show metabox value last post excerpt, title and link
  37. Change the default blog post post attribute template name from “default template” to something else
  38. if in category but only with post meta
  39. Is it possible to add a shortcode below post title?
  40. how to give multiple post thumbnails to a post
  41. Post filtering is returning blank page
  42. Change the number of excerpts displayed in search results layout
  43. wp_query with ajax
  44. Update post meta within save_post action
  45. Display post number by category
  46. Updating post meta for checkbox
  47. Saving Post Data in Another Database
  48. the_excerpt is displaying excerpts of every post
  49. Using wp-cli and delete everypost first image
  50. How to display post title inside thumbnail?
  51. Updating permalink structure using ‘post_link’ filter results in 404 error for posts
  52. How include css class based on post ( in loop ) slug?
  53. Custom permalink for each post
  54. How can I tell if a post has been published at least once?
  55. Restrict displaying posts to the poster itself (in Back-end)
  56. Why excerpt is Displaying same in Random Posts list
  57. Is there a way getting post fields using `transition_post_status`
  58. Post Title to featured Image ALT
  59. Automatic blog page with custom design [closed]
  60. Add multiple meta keys to a post at once
  61. Show number of posts by logged in user
  62. How does WP decide how to display a page
  63. Get featured image on hover of post title [closed]
  64. Exists filter or action that change Add New Post link?
  65. When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
  66. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  67. Insert data from custom created PHP page into wp_postmeta table
  68. Adding a meta box to determine the sidebar [closed]
  69. The loop starting at a certain ID
  70. content summary of a post disappears If an images added at the beginning of the post. how to solve it?
  71. saving/reading custom field value does not work – no value gets POSTed
  72. Simple Custom Metabox Not Saving
  73. Remove Featured Image from posts in specific category?
  74. Get post category as a separate string and url
  75. Retrieve a specific post’s featured image and show on a different page
  76. Only show featured image on exerpt and exclude images in post
  77. changing parent_id on post
  78. WordPress Excerpt Paragraph Limiting
  79. How to display Post title By ID and its Thumb Contents
  80. wp_list_categories() Exclude All Categories Except One
  81. Grab value of excerpt_length
  82. Get current taxonomy and display query accordingly
  83. Calling Permalinks With PHP
  84. Trying to exclude custom posts based on date, while sorting by custom field
  85. can’t modify post title using the_posts filter
  86. Show only posts with titles/permalinks that do not contain certain words
  87. How do I display main query posts in random order using add_filter
  88. How to Remove HTML Elements from Post Excerpt?
  89. Featured Images most often doesnt appear
  90. How to add text before post_excerpt in Gutenberg
  91. Rewrite image links from attachment id to attachment link
  92. Post meta not working
  93. user_has_cap filter allows “edit_others_posts” but not is not allowing updating/publishing
  94. Delete media from the post but keep my featured image and post
  95. Using AJAX to filter posts without refreshing page
  96. Why is WordPress showing a blank excerpt for just one of my posts?
  97. How to bulk Update URLs to new values?
  98. Select another post in a post meta like a parent page is selected while editing a page
  99. SQL DELETE multiple post_meta on single and multi-sites
  100. Filter posts by month (dropdown)
Categories posts Tags excerpt, filters, post-meta, post-thumbnails, posts
Why do I sometimes get an attachment id string instead of a url from an image’s guid field in the post table?
How to add text to header below title but above nav

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