Look at this
http://codex.wordpress.org/Function_Reference/the_post_thumbnail
second argument in this function you can set a few set fields, such as alt, title, source and class:
$default_attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( wp_postmeta->_wp_attachment_image_alt )),
'title' => trim(strip_tags( $attachment->post_title )),
);
Related Posts:
- How to make excerpt image be full size instead of thumbnail?
- apply_filters to featured image
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- Using classes instead of global functions in functions.php
- What is the difference between wp_register_sidebar_widget and register_widget?
- Change admin bar to default:off
- Create “File-less” Page Template in Functions.php
- How to add a 2nd “featured image” to a post?
- When to use esc_url, esc_html, esc_attr, and friends?
- How to edit bbPress template files – WordPress + BuddyPress + bbPress? [closed]
- Why might $input (Settings API) be coming through empty?
- Unexpected width and srcset attributes for the_post_thumbnail();
- Override default cropping in WordPress [duplicate]
- Get password when user registers and save it sha1 into database
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Removing the default sidebar from admin panel
- Merging PHP download script into `functions.php`
- Is there an error in get_the_tag_list()?
- Returning Variables back into a template
- How to handle thumbnails
- Allow users to add custom functions to wordpress theme
- Change date number to another language/script?
- How to add custom template tag in wordpress theme?
- Nesting Functions within Functions
- Is using eval() ok in this scenario
- Change display of featured image for pages in twenty seventeen theme
- Custom php page in WordPress theme?
- How to set dimensions of the post thumbnails (featured images)
- How to regenerate thumbnails when they’re stored on S3
- Can’t access WordPress functions in file called via Ajax?
- Cannot get full thumbnail size using the_post_thumbnail
- How can I customize wp_footer, where is the code that controls what this function does?
- How to list all images in uploads directory except those that are attached to any post
- How to make thumbnail image fit into a div where image dimentions are completely different?
- More than one meta field in a single meta box?
- Is there a theme function for is_password_protected()?
- how do you create an admin interface in plugin for your theme
- How to determine which custom header image is being shown
- Toggle Sidebar Display
- How to store functions in… functions.php?
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- trying to use wp_handle_upload with ajax
- Can’t show custom post thumbnail sizes as background images
- Should I use include or load_template for including shortcodes, plugins and so on?
- Check if home.php and set home.php as page_on_front
- Featured Images are not able to be set
- Display recent posts with thumbnail
- Reasons why all thumbnail sizes aren’t working
- Should I use add_filter for functions in function.php of the theme?
- after renaming my wp-content folder, how do I upgrade my wordpress version?
- How do I Add images uploaded in the post to a default custom field
- Pass variable to hook. Its possible?
- 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
- Theme Customizer not loading JS for live preview
- Remove “You are using WordPress 3.2.1” from Right Now Dashboard Widget
- Replace function in a child theme
- Redirect to another page using contact form 7? [closed]
- Custom theme, contact form 7 & fast secure form doesn’t work
- Featured Image meta box not showing up
- How do I remove inline style in featured image markup?
- Change the “Default Avatar” admin option via functions.php
- Replace single_template filter with what for default posts?
- Check if the image size is available and if not use ‘full’ image size
- 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?
- JQuery undefined and Stylesheet loads in bottom along with js files
- the_post_thumbnail() get the URL to the “medium” sized image
- How to call the_time current?
- Full width featured thumbnail
- Add content after get_header
- Can’t change theme name
- How to set default values for edit_post_link() in my theme?
- How to add icon over specific thumb
- How can I get the featured image or the first image for a post/page and display it as a banner?
- 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
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- Created blank theme for REST API, featured image not appearing on admin side
- Full width thumbnail
- Featured Image Module Randomly Disappears
- Single Featured Image Repeating
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- enqueue script if page is not equal to
- Mamp pro permalink issues. Pages keep reverting to index.php
- loading custom.js file after jquery is loaded
- Show post thumbnail only if it exists using timthumb
- Display Page featured Image as well as Posts featured Image
- Creating custom function in wordpress to return data from database
- Getting URL of Resized Image
- Adding a new layout for genesis
- themeforce (happytables framework) implementation
- How do I work with responsive images in WordPress? (img srcset/sizes)
- I want to resize post featured image without cropping image. How?