the_post_thumbnail()
does not return the path of your image. Instead, it returns the complete HTML markup for that image.
You can use this instead:
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); echo $image[0];
If you want a specific size you can pass an additional parameter:
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); echo $image[0];
You can either use a keyword for the size (thumbnail
, medium
, large
or full
), a size you defined with add_image_size
, or pass an array with your desired size like so: array( 100, 200 )
Related Posts:
- Image getting out of container [closed]
- How to add animation the featured image?
- Add second background-image on hover
- Plugins not showing up for custom template
- Equal height sections in custom Headway Theme
- Login validation on wordpress
- adding additional class to get the post thumbnail [duplicate]
- HTML5/CSS3 Polyfill for wp-login.php
- How to make this splash page responsive
- What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?
- Set line spacing
- Outline effect to text
- create a white rgba / CSS3
- Using CSS for a fade-in effect on page load
- Transition of background-color
- css: how to center box div element directly in center?
- Transitions on the CSS display property
- What’s the HTML to have a horizontal space between two objects?
- HTML/CSS float: left; is not working properly
- How to get current screen width in CSS?
- margin-right is not working with my HTML. How can I center my content?
- CSS div width not working
- Positioning background image, adding padding
- CSS Box Shadow – Top and Bottom Only [duplicate]
- Click through div to underlying elements
- Responsive iframe with max width and height
- Overflow-x not working
- Inner glow effect of button
- Hexagon shape with CSS3
- CSS selector for first element with class
- How make theme css be first and not plugin css
- One WordPress and database but multiple subdomains
- How can I remove css from a child theme?
- Can “ and “ tags be used in the HTML editor?
- wordpress in wamp lan doesn’t load css
- JavaScript added as link/stylesheet
- Add Post Status to Body Class
- Why does my dissappear?
- Accessing Style Sheet Comment Like WordPress
- wp_enqueue_style – CSS Not loading – ERR_TOO_MANY_REDIRECTS [closed]
- Help with child theme enqueuing additional css files
- Bootstrap in theme
- How to integrate my HTML and javascript into my child theme
- Website CSS not loading [closed]
- How to align full div [closed]
- Font Awesome icons disappearing [closed]
- Correct Way To Make Changes To A WordPress Theme
- How to change the full capitals font title of my WordPress Blog?
- How to add inline css code with background image in page html code?
- Header background image just stopped working
- Page layout is broken when viewing search results.
- Style file inclusion
- adding the_custom_logo(); to header
- CSS getting injected into index from somewhere after theme/custom CSS is loaded, overriding all of my CSS [closed]
- How do I change the style of just a part of the tagline?
- Having a hard time linking my css and JS files on a Boostrap to WP conversion
- Apply custom css for user role
- Reduce font size [closed]
- override a css style [closed]
- How to avoid repeating similar properties for all tds of a table in a wordpress post
- Using css class selectors on a specifc page [closed]
- Loading bbPress CSS file only on forum directory
- How can I force the WordPress visual editor to preserve the line breaks after paragraphs?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Override All CSS with Custom CSS on a Page by Page Basis
- padding not working
- Hide Some Fields of Post Submit box
- CSS properties in textarea in the Customizer
- New Styles Not Rendering On Mobile Phone and Tablet
- WordPress default theme CSS version problem and not loading
- Penscratch 2 – changing color of the main block
- how to modify html on homepage (no home-page.php in my theme)
- Remove dashicons.min.css conditionally
- Remove Parent Style on Carousel
- how does additional css rendering work?
- How to customize the size of Featured Images or Post Thumbnails in WordPress?
- Text Not Wrapping Around Right Floated Image [closed]
- WordPress – Portfolio – Change number of items in a row
- Floated element floats into post content in IE, Safari, and Chrome
- I cannot make this position properly in WordPress [closed]
- Featured images are cropped on index and post page
- How can I pass a variable from PHP to LESS?
- Large Unwanted Space at the Bottom of Blog Posts [closed]
- Create a body div using CSS [closed]
- vertical menu bar css
- After upload on server 404 on all pages, no css
- Strange symbols on page [closed]
- Image width issue in IE [closed]
- I need css code to divide my webpage sections into two columns
- Images at the same vertical position in multiple columns
- Put CSS on TOP, how?
- I am trying to apply these CSS rules to x3 Post-ID’s but I can’t get it to work – any idea how I can?
- In which file can I find the custom CSS code I entered?
- Some times CSS not Applying
- CSS does not take effects and it doesn’t show in inspect [closed]
- Add Quicksand for mobile devices
- Remove / Disable default custom.css?ver=1.0.0
- How to remove class=”wp-block-heading” from Heading tags?
- Website is not showing updated CSS
- How to hide button with CSS class?