To grab the img tag as a variable:
get_the_post_thumbnail ( int $post_id = null, string|array $size="post-thumbnail", string|array $attr="" )
or if you want to outright echo it:
the_post_thumbnail ( string|array $size="post-thumbnail", string|array $attr="" )
Most things like the post content, excerpt, title etc, are acquired using functions like this so that filters and hooks can be used. I’d recommend you use the get_ versions rather than the the_ versions, so that proper escaping and sanitisation can be applied
Further reading:
Related Posts:
- What’s the difference between home_url() and site_url()
- Prevent “main” WPMU site_url() being returned in functions
- Custom page with variables in url. Nice url with add_rewrite_rule
- Is it possible to use a forgot password url filter?
- Create Custom URL structure for specific Post category
- How can I rename the WordPress AJAX URL? [duplicate]
- Ninja form Redirect depending on text field content [closed]
- wp-comment author- url +, email filter hook
- Removing custom meta data
- WordPress on AWS Auto scaling and ELB giving 503
- WordPress converts media extention URL automatically to video player
- meta tags doesnt fetch data from permalinks
- Get arguments from URL
- Add unique id to Preview URL
- How can I set the SRC URL of the custom logo image?
- Need to convert image url to a Base_64 data url with wordpress function..
- Protect get_query_var from manual input in url
- Problem with images URL after filter applying
- How i can get the URL?
- include w_thumbnail_src in function?
- Create Custom URL structure for specific Post category using Post ID instead of post name
- Fetch URL parameter
- how can I change all wordpress media file url to custom cdn url?
- Custom route and extract data from slashes and parameter
- reWrite wp-content url to point on my cdn
- How to Override Page Template if URL matches query?
- Add #primary at the end of navlink permalinks on single posts
- Set URL Parameter Post Layout As Default
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- How to add a meta information to the URL?
- How do I change the URL returned by next_posts_link()?
- Function in functions.php by url
- What is the “with_front” rewrite key?
- Filter the query ONLY for the search results page
- How to add attributes to a shortcode
- Delete expired posts after a number of days after they expired
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- Customize WordPress Media Manager – Media Window
- How to override functions.php in child theme?
- Is it possible to maintain image aspect ratio when scaling images?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- change a post status when users update posts?
- How often is functions.php loaded?
- Cleaner way to access custom fields in code?
- Add a new subscriber role using a function
- Display a text message if the shortcode is found?
- How to store / access files in child theme folder
- How to set the jpg image compression for specific thumbnail sizes?
- Function to auto-set a featured image that is already in use
- How would go about if I just want a temporary function?
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?
- Generating rel=prev and rel=next only on wordpress categories
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- How to hide unused profile fields?
- Override widget in function WordPress
- WooCommerce – Want to show multiple currency for a single product [closed]
- How to change or add user role after getting post request data about pay? [closed]
- Automatically include all php files in a child theme directory
- Difficulty with PHP function that displays a post’s format in WordPress
- Events: Check for other event with same start date and category [closed]
- Function coding error concatenating quotes I think
- Need print logo without any ID & class
- Can we create our own theme’s function.php?
- Not all CSS elements transferring via parent to child?
- Reset postdata not working on WP_Query in functions.php
- Filter nav menu items HTML tags and wrap inner text with span
- Using Static HTML instead of the `home_url()` WP function
- How to append classname to body tag if guest user
- add_filter to specific WooCommerce Category
- Can I include a custom PHP function in a WordPress function?
- Function to replace comment’s accented characters before posting
- wp_nav_menu work in functions.php but not in the theme
- Only echo Page Content (not page title & page content together)
- How do I preserve changes to a theme’s functions.php across updates?
- Unable to Change “Pages:” Before WP_LINK_PAGES
- Looking for Functions File that doesn’t Exist
- Updating custom query var with multiple values
- Redirect to one of two pages after data submitted, depending on the current url
- WordPress wp_dequeue_script remove all other scripts
- Add Javascript code to functions.php childtheme
- Why does my wp_enqueue_script() only insert the script for logged in users
- method to fetch entire tag list on archive.php
- MCAPI.class.php showing some error
- Limit Number of Posts on Blog Category Page Throwing 404 Error on Paginated Pages
- How can I return the result of my custom function?
- Excerpt length: get 2 paragraphs
- Remove heading tags on line break
- Removing all my hardcoded URLs with get_site_url()
- Sort results by name & asc order on homepage
- I want to add the alt attribute to all the photos!
- Please give me the rewrite rules for my ugly urls
- Creating mixture of shortcodes to use in the visual/text editor
- WordPress Custom wp mail template return full template
- Comment turned Invisible
- BuddyPress Edit activity function good practice
- wp_login_form display no styled form
- Would it be possible to disable embeds for specific user roles? If so, how?
- Cron Register everytime if i reload admin if i pass some extra argument in wp_schedule_event function
- Add custom text before all image captions in WordPress posts