The function to use would be:
$url = get_the_post_thumbnail_url();
However, that’s not the most helpful for you right now, so we have a meta field with placeholders that you need to swap out for URLs before outputting.
breaking that down we get these smaller steps:
// grab the field
// grab the URL
// swap the placeholder out for the URL
// output the field
So lets do each individual bit:
// grab the field
$meta = get_post_meta( ....
// grab the URL
$thumb_url = get_the_post_thumbnail_url();
// swap the thumbnail placeholder out for the URL
$meta = str_replace( '%thumbnail%', $thumb_url, $meta );
// output the meta field
echo wp_kses_post( $meta );
Notice the wp_kses_post
which strips out dangerous HTML while letting you keep img
tags etc
Related Posts:
- How can I make add_image_size() crop from the top?
- What plugin can I use to create a list / slideshow of featured images?
- Prevent publishing the post before setting a featured image?
- Modify featured image URL at runtime
- Add post thumbnail from external image with plugin
- Thumbnail with different sizes
- Meteor Slides as header only for homepage and Use featured image of each page as header for respective pages
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- AJAX image upload with a upload progress bar using media_handle_upload
- Converting Attachment to Images?
- ReOrder Post Within Categories plugin with featured image
- Any Short code Availble for Get Post List With Thumbnail Plugin?
- Set featured image using javascript in post editor
- Add padding while generating thumbnail
- How to export all content with feature images?
- Redirect to another page using contact form 7? [closed]
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- Plugin to hide image in excerpt
- Cropping images from top center using Jetpack Photon
- Add “Featured Image” box in my plugin post page
- Couple of beginner’s questions [closed]
- Scrape a webpage for image and add it to post
- Adding featured image to posts created by a plugin
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- Add_image_size not generating correct size
- Multiple Post Thumbnails Plugin – Need help with code
- How to hide featured images of all posts falling under the same category in wordpress?
- Revision featured image
- Allow webp use on website but disallow webp as featured image during post creation
- Upload Image with a file URL and show dynamically on Frontend
- insert og image link in wordpress post
- How to Add call button on a featured image in a wpsite? check the slap king image, there are two buttons on the featured image
- Display Multiple Photos as Featured Image when mouse moves on to it post
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- automatically set random featured image by category in wordpress on post
- Import 2000 posts from one website to another
- Hide Featured Image in AMP
- WordPress create thumbnails on demand
- Automatic set a featured image from the first image’s url (or tag) in the article
- Does WordPress have a way of changing the ‘Natural’ size of uploaded images?
- Update (a function) post’s featured image as soon as $image_url changes
- Can’t get or display post thumbnail in wordpress
- Adding featured image to post display widget
- Do something with thumbnail image on post publish
- How to force regenerate thumbnails in WordPress posts?
- How to add featured image on front end form?
- Lazy Load sometimes don’t work
- Determine if get_the_image has image on Get the image Plugin
- Advanced Custom Field User Help URL
- Retrieve post thumbnails
- featured image problem with custom post type
- Looking for a related post plugin which slides-in like the one at inc.com does [closed]
- when i use wp automatic plugin post shows broken images
- Display Video as Post Thumbnail
- Multiple Post Thumbnails Not Returning URL for Background Image
- How does WordPress official repository estimate ‘Active Installs’ of a plugin?
- Disable plugins on cron and ajax page
- Convert WordPress pages to PDF
- Automattic’s eCommerce Plugin
- Is there a plugin to protect downloads with recaptcha?
- Problem running Ajax in WordPress
- Counting pageviews on high-traffic cached sites
- Questions about brute force attacks on the admin username, coming from amazon IP addresses
- What’s the _wp_desired_post_slug value for?
- Correct wp-content ownership and permissions
- WooCommerce: Change default country on the cart page [closed]
- How can I list recent posts excerpts?
- Should I fetch the data managed by a plugin by using its APIs or WordPress APIs?
- Use translated taxonomy labels in plugin
- Scripts at the end of the page
- WordPress Payment gateway add on form , how to add form into list or else how to submit form to next step for payment
- How WordPress is able to change locale without using setlocale
- Better ads plugin has 500.000 entries in wp_postmeta
- PHP Fatal error: Call to a member function locale() on a non-object
- Shortcode Placeholder Plugin
- WordPress plugin url for form submit
- how to place a link on the first post only using a plugin
- Minimizing scripts & css files that plugins add
- How to setup a product that has multiple price options? [closed]
- correctness of URL
- Override plugin template
- WordPress Update Question
- navigation among single posts
- Plugin access and Roles
- Custom Post Type same name as Category
- how to display recent post by category on home page
- How to display the custom post related blog by category?
- Overriding inline !important CSS with Javscript code snippet with media query
- Accessing data from Google Cloud Datastore in WordPress site
- Login issue in WordPress
- How to create multiple pages for PDFs
- How to Call Function From Separate WordPress Install on Same Server?
- How to echo a plugin’s function into a template?
- How to assign plugin to top level menu?
- Login redirect to dynami url – currently using Peter’s Login Redirect
- Multiple Accounts on 1 email – Multisite
- Excluding CPT generated by a plugin from the loop
- Is it possible to send user new password after they clicking on forgot password in word press
- How to display blog posts only authored by the administrator
- Meta box not displaying on the plugin page