admin管理员组

文章数量:1122846

I'm trying to add an image caption below my featured image on my single posts. I have this working, but weirdly they are also displaying above the image. I'm hoping someone can help point out the issue in my code below. Thanks for your help.

function your_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr){
    if (is_single()){
        $attachment =& get_post($post_thumbnail_id);

        if ($attachment->post_excerpt || $attachment->post_content) {
            $html .= '<p class="thumbcaption">';

            if ($attachment->post_excerpt) {
                $html .= '<span class="captitle">'.$attachment->post_excerpt.'</span></p>';
            }
            //$html .= '<a href="'.$attachment->post_content.'">Link To Asset</a></p>';
        }

    
    }
    return $html;
}

add_action('post_thumbnail_html', 'your_thumbnail_caption', null, 5);

本文标签: functionsHow Do I Prevent Featured Image Caption Displaying Above And Below Image