So first off, I hope you’re aware that the quote there is a guideline on how should a post of the image
format be displayed to the user, and the thing about the title attribute applies only to posts where the format is image
and that the post content is the image URL only, e.g. https://example.com/image.jpg
.
what title attribute they are talking about
It’s the title
attribute of the <img>
tag, and the attribute value should be set to the post title.
how to retrieve that title through PHP
There are some functions you can choose from such as get_post_field()
, get_the_title()
and the_title_attribute()
.
So for example, your <img>
can be generated like so:
<img src="<?php echo esc_url( get_post_field( 'post_content' ) ); ?>"
title="<?php the_title_attribute(); ?>">
Related Posts:
- WordPress Theme Preview Image
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- Are content.php and content-single.php the same?
- How to modify an image block in Gutenberg WordPress 5?
- How can I set image sizes and still have responsive images using the srcset attribute?
- Add default Backgrounds
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- Specify image dimensions
- How to get gallery images?
- add_image_size is scaling, even though crop is set to true
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- Confused about image sizing business in WordPress
- Unexpected width and srcset attributes for the_post_thumbnail();
- How do I get gallery thumbnail URL and change the default thumbnail size?
- Responsive class to all the images in the content
- How wordpress handle upload images and how to use them in the code
- Replace Home with image link inside custom header menu
- Featured Image Size
- How to set dimensions of the post thumbnails (featured images)
- Cannot get full thumbnail size using the_post_thumbnail
- wp_get_attachment_image_src() width and height boolean
- How to float an image in Gutenberg
- A mystery 300px image size
- Custom Field returning Numerical Value for Image rather than URL
- show a post from a specific post format
- Why an arugment is missing in wp_get_attachment_image_attributes?
- Reasons why all thumbnail sizes aren’t working
- How to make a local cache of mshots images
- How do I Add images uploaded in the post to a default custom field
- attachment.php code or tutorial
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?
- image url relative path not working in css file
- Default image size not working
- WordPress Media Uploader in page template (On Front-end)
- What’s the best practice way of handling custom fields in different post formats?
- Responsive Images – crop don’t seem to work
- How do I include pre-installed images in a theme?
- Inserting images in multiple posts native gallery
- Can I get the ID of an inserted / linked image?
- Add attachment for all images in post
- Changing Header Image Every N Minutes/Seconds
- Displaying icon image for WordPress post formats, is there a cleaner way to do this?
- Do not display post images on front page
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Gallery thumbnails very small
- Custom image size vs CSS sizing
- Getting Different Size Of Attachment Images
- In creating a theme, how can i allow a user to change an image outside post/page content?
- Change Responsive Images Maximum Width of 1600px
- How to show a manageable list of images on a post?
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- Change image size depending on page
- How to disable thumbnail filter for a specific template part or image size?
- How to obfuscate theme directory URLs
- Are seven additional image sizes are too many?
- Remove link on full-size images
- How can I prevent posts with no title showing up in my query?
- How do I get standard posts to open up in their own template when using get_template_part()?
- Theme logo metadata into template file
- WordPress creating images if uploaded image is greater than 960px on one side?
- How to fix WordPress images not showing up in local hosted XAMPP server?
- Change Image Sizes for Mobile Theme
- Stop WordPress from showing images on non post pages
- How to make excerpt image be full size instead of thumbnail?
- How to add cropped custom header image?
- Is there a way to serve different resolution images to different devices?
- 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?
- Adding link post format to theme and permalink to rss feed
- How can I remove image taxonomy pages from my theme and from Google?
- Dynamic Image Links Depending on Excerpt/’Single Post’ View
- Designing a custom archive.php inspired by the Autofocus theme
- ACF get_sub_field ALT TAG in the repeater doesn’t show
- WordPress Animation Adjustments
- theme directory fallback image outputs url and not the image
- Post Featured Image Custom Sizing?
- Image cropping isn’t working correctly when using Offload Media
- How to add an image to a theme page template in code?
- Responsive Images with art direction
- Customizer Image-Picker Preview Not Working
- Uncaught Reference error in Retina.js
- Can’t upload images on new theme
- Images use & location, on new wordpress theme
- image sizes – finding and removing
- Adding a Class to an Getting From Post Content
- Create image with imagepng() (fails at header)
- How do I keep images in posts below a certain size without editing the post?
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- the_post_thumbnail fetches wrong image
- Custom image size doesn’t work
- Retina ready for uploaded images which are cropped
- Add rel to all images in a post
- How can I add a single image from a gallery into the page header?
- Isotope overlapping .items because of featured images – HELP! [closed]
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- I want to resize post featured image without cropping image. How?
- How to override BuddyPress 3.0 bp-nouveau theme files?