Code snippet for Featured image caption causing weird issues
-
Hello, i am using a code snippet wich is causing weird issues in my posts. Right now i have about 60 plugins in my wordpress site. If i use the code snippet locally, everything works fine. But in production, my posts create the 502 error. Here is the code:
add_filter( 'post_thumbnail_html', 'custom_add_post_thumbnail_caption',10,5 ); function custom_add_post_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) { if ( !$html == '' && is_single() ) { // Get Excerpt of thumbnail $thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment')); $thumbnail_caption = $thumbnail_image[0]->post_excerpt; if ( $thumbnail_caption ) { $html .= '<div class=""> <p class="">'. $thumbnail_caption .'</p> </div>'; } } return $html; }Why can i be doing wrong? Thanks in advance.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Code snippet for Featured image caption causing weird issues’ is closed to new replies.