Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp_get_attachment alt text

First of all you need to get attachment ID for getting alt text..

Use this code to get that,

$img_id = get_post_thumbnail_id(get_the_ID());

Now add your code,

<?php $alt_text = get_post_meta($img_id , '_wp_attachment_image_alt', true); ?>

<h1 class="entry-title"><?php echo $alt_text; ?></h1>
Comment

PREVIOUS NEXT
Code Example
Php :: php copy image from remote to local server 
Php :: laravel middleware route 
Php :: delete file in php 
Php :: unable to open file error in php 
Php :: how to get plugin directory path in wordpress 
Php :: get users of specific role laravel role spatie 
Php :: php 8 constructor promotion 
Php :: show float laravel blade 
Php :: timezone php 
Php :: remove item in an array php 
Php :: format seconds to human readable carbon 
Php :: php clone datetime 
Php :: php global variable function 
Php :: date to string php 
Php :: sha256 encryption in php 
Php :: display error php 
Php :: how to store file in public folder laravel 
Php :: replace in php 
Php :: get class name from object php 
Php :: carbon previous day 
Php :: laravel upgrade php version 
Php :: Class "Controller" not found 
Php :: run xampp application on windows startup 
Php :: laravel how to check if there are record exists 
Php :: action after model is created laravel 
Php :: if is front end wp 
Php :: Extract Numbers From a String in PHP 
Php :: how to get ip address of pc in php 
Php :: php array sum 
Php :: php rand vs mt_rand 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =