• Hi there,

    I have trouble on a website with the featured image – it does not link to the main post page anymore. I cannot remember whether it did before, but I think so. Anyway, the owner of the website asked me about this issue and I could not solve it. I hope someone here might help me. Below you’ll find the code from the function.php and the website is built on Cudazi Mono theme (if it makes any difference).

    // Get Featured Image + Link
    	function cudazi_get_featured_image( $img_size, $fallback ) {
    		global $post;		
    
    		$cudazi_post_hide_featured_single = get_post_meta($post->ID, 'cudazi_post_hide_featured_single', true);
    		if ( is_single() && $cudazi_post_hide_featured_single ) {
    			return false;
    		}
    
    		if ( has_post_thumbnail() ) {
    			$featured_image_link_to = get_post_meta($post->ID, 'featured_image_link_to', true);
    			$featured_image_link_to_url = get_post_meta($post->ID, 'featured_image_link_to_url', true);
    			if ( $featured_image_link_to_url ) {
    				$featured_image_link = $featured_image_link_to_url;
    			}else{
    				if ( $featured_image_link_to == 'post' ) {
    					$featured_image_link = get_permalink();
    				}else if ( $featured_image_link_to == 'image' || !$featured_image_link_to ) {
    					$featured_image_link = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    					$featured_image_link = $featured_image_link[0];
    				}
    			} // end if url set
    			$featured_image = get_the_post_thumbnail($post->ID, $img_size, array( 'class' => '' ));
    		}else{ // no thumbnail set
    			$featured_image_link = get_permalink();
    			$featured_image = $fallback;
    		} // end if has featured image				
    
    		if ( has_post_thumbnail() ) {
    			return "<div class='post-thumbnail'><a href='" . $featured_image_link . "'>" . $featured_image . "</a></div>";
    		}
    	}

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Featured Image Link not working’ is closed to new replies.