This is wrong
<?php if ( have_posts() ) {
while ( have_posts() ) {
if ( has_post_thumbnail() ) {
echo "<div id='post_thumbnail'>";
the_post_thumbnail();
echo '<h4>' . get_post(get_post_thumbnail_id())->post_excerpt . '</h4>';
echo "</div>";
}
the_post();
You are calling your thumbnail before the_post()
. Just move the_post()
to before if ( has_post_thumbnail() ) {
Related Posts:
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- How to add a 2nd “featured image” to a post?
- How to change post thumbnail title and alt attributes to post title?
- Unexpected width and srcset attributes for the_post_thumbnail();
- How to handle thumbnails
- Change display of featured image for pages in twenty seventeen theme
- How to set dimensions of the post thumbnails (featured images)
- How to regenerate thumbnails when they’re stored on S3
- Cannot get full thumbnail size using the_post_thumbnail
- Can’t show custom post thumbnail sizes as background images
- Featured Images are not able to be set
- Display recent posts with thumbnail
- Reasons why all thumbnail sizes aren’t working
- How do I Add images uploaded in the post to a default custom field
- How do I build a post_thumbnail based archive? [closed]
- How do I turn a post thumbnail into a background image?
- Reactor Theme: Prevent Post Thumb on Post
- Featured Image meta box not showing up
- How do I remove inline style in featured image markup?
- Set a featured image as a replacement to the header image
- Dynamic Post Thumbnail →
- Issue on Getting Custom post type Thumbnail’s URL
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- How to disable thumbnail filter for a specific template part or image size?
- the_post_thumbnail() get the URL to the “medium” sized image
- Full width featured thumbnail
- How can I get the featured image or the first image for a post/page and display it as a banner?
- How to make excerpt image be full size instead of thumbnail?
- How can I scale down the width of images in bulk that are embedded in posts throughout the site?
- Add image URL automatically to custom field?
- theme directory fallback image outputs url and not the image
- Created blank theme for REST API, featured image not appearing on admin side
- Full width thumbnail
- Featured Image Module Randomly Disappears
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- apply_filters to featured image
- Show post thumbnail only if it exists using timthumb
- Display Page featured Image as well as Posts featured Image
- How do I work with responsive images in WordPress? (img srcset/sizes)
- I want to resize post featured image without cropping image. How?
- Software for WordPress Theme and Plugin Development? [closed]
- Should we use get_template_part() in functions files instead of include_once?
- Reset positions of metaboxes in admin
- Add a dropdown to theme customizer
- design and development workflow
- How to control initial wp_head() output?
- enqueue script for specific shortcode
- Why might $input (Settings API) be coming through empty?
- add generated stylesheet from parent theme after child-themes style.css
- Creating Page Based on Category
- How to check if post has any tag?
- Merging PHP download script into `functions.php`
- Should use widgets in this case?
- Get last modified date for menu link
- A theme that follows all the best practices to learn from?
- WordPress how to override function adjacent_posts_rel_link_wp_head() in link-template.php the correct way
- Can wordpress run in root of existing php site with no theme on index.php but all other WP posts/pages?
- CSS won’t style output of wp_nav_menu() correctly
- after_setup_theme, Global Variable and Theme Customizer
- How to make WP admin recognize a newly created child theme?
- Theme translation not applying
- How to add filter the post thumbnail before save in database?
- Custom theme development additional pages
- How to add material design css in wordpress and woocommerce
- How to set the currently active page in the menu including parents
- changing blog title to an image using filter function in child theme
- WordPress taxonomy and archive custom class
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- How to remove text “Log In” from login page
- Website pagespeed problem
- Managing WordPress Theme
- next_posts_link and previous_posts_link problem
- Data Validation in wordpress
- Gutenberg theme development: how to add “headers” option under styles > colors > elements?
- Localize script not working in ajax
- How to override template files in parent theme?
- How can i make multilevel menu in wordpress theme with bootstrap
- Remove div element generated automatically from theme [closed]
- How to use the _S framework
- How to link to the page displayed by home.php?
- AJAX call fails when sending JSON but works with URL style string
- How to get a random single category name in get_posts()?
- WordPress theme files Organization
- Put CSS Content inside tag for WordPress
- How to display latest posts with authors image
- How can I convert a list of title-posts into a sequence of comma separated text? [closed]
- Is it possible to issue a theme update that requires a new plugin?
- Get property of non-object on theme activation
- change wordpress website logo url [duplicate]
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- How to add custom field option with menu?
- save prevision data in the database on theme activation
- How to remove menu from WP-Admin menu
- How do I move menu to the bottom in Custom Community theme?
- How do I get information about a page, such as featured image, except, and title?
- Insert gutenberg blocks into template
- How to make it so I can “use” template parts in (classic/full) site editor