Home / Admin / Fix Image Caption Rendering Issue Caused by WPResidence Theme
Duplicate Snippet

Embed Snippet on Your Site

Fix Image Caption Rendering Issue Caused by WPResidence Theme

This snippet fixes the Image Caption Rendering Issue Caused by WPResidence Theme

<10
Code Preview
php
<?php
if(!function_exists('wp_get_attachment') ) :
    function wp_get_attachment( $attachment_id )
    {
        $attachment = get_post($attachment_id);
        if( $attachment ) {
            $caption = function_exists('aioseoImageSeo') 
                ? aioseoImageSeo()->tags->replaceTags(aioseo()->options->image->caption->format, $attachment->ID, 'caption') 
                : $attachment->post_excerpt;
            return array(
                'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
                'caption' => $caption,
                'description' => $attachment->post_content,
                'href' =>  esc_url(get_permalink($attachment->ID)),
                'src' => $attachment->guid,
                'title' => $attachment->post_title
            );
        } else {
            return array(
                    'alt' => '',
                    'caption' => '',
                    'description' => '',
                    'href' => '',
                    'src' => '',
                    'title' => ''
            );
        }
    }
endif;

Comments

Add a Comment