Better way to show Description and image Captions
There is nothing WordPress specific here, but you could make your code easier to read by removing the repeating parts. if ( $id = get_post_thumbnail_id() ) { $post = get_post( $id ); $data = array( $post->post_content, $post->post_excerpt ); // remove empty elements from array $data = array_map( ‘trim’, $data ); $data = array_filter( $data ); … Read more