با سلام
اگر از تصویر شاخص استفاده کنید می تونید از این کد استفاده کنید :
[PHPS]<?php
if( has_post_thumbnail( $post->ID ) &&
$image = /* $src, $width, $height */ wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
$image[1] >= HEADER_IMAGE_WIDTH ) {
/* Retrieve the full "post" object for the featured image */
$thumb = get_post( get_post_thumbnail_id( $post->ID ) );
/* Check to see if the caption or description is a URL */
if( !empty( $thumb->post_content ) && substr( $thumb->post_content, 0, strlen('http') ) == 'http' ) { /* The "Description" field is a URL */
$thumblink = $thumb->post_content;
} elseif ( !empty( $thumb->post_excerpt ) && substr( $thumb->post_excerpt, 0, strlen('http') ) == 'http' ) { /* The "Caption" field is a URL */
$thumblink = $thumb->post_excerpt;
} else {
$thumblink = NULL; /* Set this to anything else if you want the header image to link to a default item when no URL is provided in the "Caption" or "Description" section */
}
/* Echo either the linked featured image or the regular featured image, depending on the value of the $thumblink variable */
echo ( !empty( $thumblink ) ) ? '<a href="' . $thumblink . '">' . get_the_post_thumbnail( $post->ID, 'post-thumbnail' ) . '</a>' : get_the_post_thumbnail ( $post->ID, 'post-thumbnail' );
} else { /* Output the default header image if the requirements for a thumbnail were not met above */
?>
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
<?php
}
?>[/PHPS]