How to link all featured images to custom url in single.php for only non-logged-in users?

In single.php you can wrap your featured image in a link tag with a conditional to check if the user is logged in.

    if ( is_user_logged_in() ) {
        echo '<a href="https://google.com/">';
    }

    the_post_thumbnail();

    if ( is_user_logged_in() ) {
        echo '</a>';
    }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)