• Hi ! If a post is protected with a password, its thumbnail is hiden until the password is entered. I found nothing about password in singular.php and I just found this (about password) in my content.php child-files :

    <?php
    
    $thumbnail_url = ( has_post_thumbnail() && ! post_password_required() ) ?  get_the_post_thumbnail_url( $post->ID, 'post-thumb' ) : '';
    
    $style_attr = $thumbnail_url ? ' style="background-image: url( ' . $thumbnail_url . ' );"' : '';
    
    ?>

    I moved && ! post_password_required(), but it doens’t work.

    Please, could you help me ?

    Many thanks.

    Best regards.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sorry, if I hijack this topic, but I’m very interested in this, too. I have some password protected posts on my site, and it looks somewhat ugly if the preview images (featured images) aren’t shown on the homepage.
    Is there a workaround for this?

    Thread Starter axbx

    (@axbx)

    Hi !

    In your content.php you have probably :

    <?php
    
    $thumbTrnail_url = ( has_post_thumbnail() && ! post_password_required() ) ?? get_the_post_thumbnail_url( $post->ID, 'post-thumb' ) : '';
    
    $style_attr = $thumbnail_url ? ' style="background-image: url( ' . $thumbnail_url . ' );"' : '';
    
    ?>
    
    <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>" <?php post_class( 'post' ); ?><?php echo $style_attr; ?>>

    Try to replace it by :

    <?php
    
    $thumbnail_url = ( has_post_thumbnail() ) ?  get_the_post_thumbnail_url( $post->ID, 'post-thumb' ) : '';
    
    $style_attr = $thumbnail_url ? ' style="background-image: url( ' . $thumbnail_url . ' );"' : '';
    
    ?>
    
    <script> $=jQuery; $('.post.post-password-required').removeClass('post-password-required').addClass ('has-post-thumbnail')</script>

    Regards.

    I tried replacing exactly like you wrote, and it crashed my whole site, unfortunately. ??

    Instead of the homepage, I was shown a broke title of one post and nothing else.

    But still, thanks for trying to help. ??

    Thread Starter axbx

    (@axbx)

    oh I’m really sorry! This code worked well for my problem, it was written to me by an administrator of the French WordPress forum.

    Did you find a solution ? Maybe you can find help on this forum in French, with a new topic ?

    https://wpfr.net/support/sujet/probleme-affichage-vignettes-si-mot-de-passe/#post-2452656

    Sorry, sorry, sorry.

    Best regards

    No worries ?? Since I always save a backup version of any file that I change, I could revert it in the blink of an eye. ????

    Thanks for the forum link, I’ll check it out. ??

    Thread Starter axbx

    (@axbx)

    Ouf !! good luck !

    Have a good day

    You too ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Password Protect hides featured images-Hitchcock theme’ is closed to new replies.