In the place where you use get_the_title($post_id)
you need to get the alt attribute that is stored in the post metadata like this:
esc_attr (get_post_meta ($post_id, '_wp_attachment_image_alt', true))
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- How to add a class to the attachment images
- How to draw media details for Isotope gallery using Photoswipe
- How to register images uploaded via FTP in media library?
- Add custom image sizes to media uploader
- Using wp_get_image_editor in a standalone script
- Change logo based on incoming domain
- Convert all images to PNG on file upload
- How to get specific image in media library with php
- Set the background to a default image if there isn’t a specified “featured image”
- How to control WordPress image metadata (using Imagick)?
- Scrape external webpage for first image and add it to new post
- Else/If Statement to Display Photo Descriptions
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Adding a ‘style=’ bit to image_send_to_editor output
- Convert all uploaded PNG files to PNG-8 format
- Retrieve alt text by referencing the img src
- not outputting medium size image URL
- How to use data URL in WordPress?
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Retrieving specific images from Media Library
- How do I routinely extract the thumbnail of the most recent post?
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Save the outputted image into the Media Library, with a different filename and extension
- add if statement to the featured image
- Remove default Image Sizes
- Understanding responsive imagery
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- Admin Media grid view images won’t load
- WordPress remove EXIF Data from specific Thumb
- How to use WordPress (PHP) functions in AngularJS partials files?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Can’t load WP function into external function
- Image as Sales Badge
- WSoD being caused by this piece of code
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Reprinting tags with all attributes
- Css loads very slow [closed]
- Why is image hard cropping for one image using add_image_size not working?
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Call to undefined function get_userdata() in plugin
- Fatal Errors on pluggable.php
- Log in / Log Out Custom Button
- how to test for all children (including multilevel grand-childern) of page
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- How to modify the default feed via a function
- require_once() if a product in woocommerce contains a tag [closed]
- Loop over Array and get the distinct ids
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Only show first image in foreach loop
- Shortcode for Listing Users from Meta Value?
- Display css ONLY on most recent post of specific category?
- How to remove the space before the ellipsis in excerpt?
- Dynamic Menu drops pages?
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- How do I call an external php non WordPress class into functions.php?
- send popup after wp_redirect()
- How to remove/hide collapse menu for user/subscriber?
- Checkbox doesn’t save inside metabox
- A function to get the content of a page
- Billing detail page doesn’t work after I’ve changed the order of the Woocommerce navigation
- Change the URL of an image from wp_get_attachment_image_src for Product Posts based on Category
- WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field
- How can I prevent a shortcode div from extending beyond its boundaries?
- Where Do Image Dimensions Get Added To A Filename?
- Get custom field value from the function.php
- Non-blocking file_put_contents in function.php
- Advance custom fields variable with if statement & Function
- Restrict wordpress access to logged users only
- Featured images duplicating and replacing next image
- How best to check if a user is from China and hide content?
- Menu to the right of screen on desktop using Bootstrap 4
- Printing OEmbed URL based on Post selected w/o page refresh
- Automatically refresh page if widget is added to page?
- How to create “page” used for generating PDF? [closed]
- Published custom posts missing
- PHP version or config prohibiting script from working properly
- static array on functions.php
- Integrating CSS Into a WP Function Call [closed]
- Change background image based on tags
- Where to store the images of a custom WordPress theme?
- Functions.php file in a custom child theme messed up without backup
- How can I fix my pagination?
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Use URL query string in img src attribute
- In WordPress how do you remove render-blocking CSS manually without a plugin?