Skip to main content
edited tags
Link
cybmeta
  • 20.6k
  • 5
  • 47
  • 56
added 1062 characters in body
Source Link
bellabelle
  • 101
  • 1
  • 6

Below is my code.

<div class="authortest-cont">
                <h2><span>W</span>hat Our <small>Authors Say</small></h2>
                <?php
                $wck_custom = get_post_meta( $post->ID, 'testimonialsbox', true);
                foreach($wck_custom as $wck_cstm) {
                    
                    $author_name = $wck_cstm['author_name'];                            
                    $author_img = $wck_cstm['author_img'];
                    $author_testimonial = $wck_cstm['author_testimonial'];
                    
                    if( is_numeric( $author_img ) ) {
                        $attach_author_img = wp_get_attachment_image_src( $author_img, 'full' );
                        $src_author_img = $attach_author_img[0];
                    }
                    else {
                        $src_author_img = $author_img;
                    }
                                        
                ?>
                
                    
                <div class="col-md-6 col-sm-6">
                    <?php echo $author_testimonial; ?>
                    <div class="author-det">
                        <img src="<?php echo $src_author_img; ?>" alt=""/>
                    </div>
                </div>

                <?php } ?>
            </div>

How echo alt value of that image?

Below is my code.

<div class="authortest-cont">
                <h2><span>W</span>hat Our <small>Authors Say</small></h2>
                <?php
                $wck_custom = get_post_meta( $post->ID, 'testimonialsbox', true);
                foreach($wck_custom as $wck_cstm) {
                    
                    $author_name = $wck_cstm['author_name'];                            
                    $author_img = $wck_cstm['author_img'];
                    $author_testimonial = $wck_cstm['author_testimonial'];
                    
                    if( is_numeric( $author_img ) ) {
                        $attach_author_img = wp_get_attachment_image_src( $author_img, 'full' );
                        $src_author_img = $attach_author_img[0];
                    }
                    else {
                        $src_author_img = $author_img;
                    }
                                        
                ?>
                
                    
                <div class="col-md-6 col-sm-6">
                    <?php echo $author_testimonial; ?>
                    <div class="author-det">
                        <img src="<?php echo $src_author_img; ?>" alt=""/>
                    </div>
                </div>

                <?php } ?>
            </div>

How echo alt value of that image?

Source Link
bellabelle
  • 101
  • 1
  • 6

How to get Image `alt` value from Wordpress image attachment?

I am using a WCK plugin to Wordpress. In the php code to call the image source, I used wp_get_attachment_image_src() but it only gets the url of the image. I want to include the alt value of it. Please help. Thanks.