Featured image won't hide on single posts

Hi there, looking for some help on featured images.

I’m trying to get the featured image to show on the main blog page, but be hidden on the single posts.

I can get it to hide on both, but I can’t get the featured image to hide on just the single posts (in Pro).

I’ve already tried the usual CSS below, to no avail.

.single-post .entry-featured {
display: none;
}

I’ve also tried:

.single-post .entry-featured,
.single-post .entry-thumb {
display: none;
}

The main page is https://thinkalt.co.uk/blog/ and the blog post is https://thinkalt.co.uk/using-your-platform-to-effect-change/

There is a block image below the headline (this is meant to be there to replace the featured image).

Thanks

Hi @danmcdevitt,

These codes will only work for single posts because of the single-post class that is in the selector.

https://thinkalt.co.uk/blog/ is supposed to be the blog page of the site so the code you are trying to use will not work.

https://thinkalt.co.uk/using-your-platform-to-effect-change/ also does not have the .single-post class to the body element.

It seems that there is something odd about your site setup. Did you upgrade the license from X to Pro? If you have, please check if the child theme installed is updated since the older versions of the child theme is slightly different from the updated ones.

Please login through FTP then go to wp-content/pro-child then check and edit the functions.php file if necessary. It should have this basic lines:

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to Pro in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Enqueue Parent Stylesheet
//   02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );



// Additional Functions
// =============================================================================

Once everything is correctly setup, this code should remove the featured image on the blog and single posts:

.blog .entry-featured,
.single-post .entry-featured,
.single-post .entry-thumb {
    display: none;
}

If you’re still not able to get it sorted, please provide us with the admin access to your site in a Secure Note:

Hi - thanks for this.

The child theme is up to date, the line of code was correct in the functions.php and the latest CSS hasn’t worked.

I am adding a secure note with login details now for you.

Thanks in advance.

Hi @danmcdevitt,

CSS is not working because default wordpress class added on the body is missing. Either it was removed in the child theme or the main Pro theme is corrupted. Please try to switch to main Pro theme. Check if that class will work, if yes, you might have a customization that removes that class. If not, please try reinstalling Pro theme. Purge cache after this and then try again.

Hi there

I swapped to the main pro theme and the issue was still there.

Have re-installed pro manually and cleared the cache and the issue still remains…

For clarity, I’d like to keep the featured image on the blog page and hide it on the single-post page…

Hi @danmcdevitt,

I checked your site and the problem was caused by this plugin Multi Form Data Storage, if you will deactivate the plugin the custom css that you have added will take effect.

But if you need the Multi Form Data Storage plugin and you can’t find an alternative plugin for it, I have another solution that will not involve deactivating it. Just add this code below in the functions.php of your child theme.

function x_featured_image( $cropped = '' ) {

  $stack     = x_get_stack();
  $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;

  if ( has_post_thumbnail() ) {

    if ( $cropped == 'cropped' ) {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
      }
    } else {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
      }
    }

    if( is_singular() == false ) {
        printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
          esc_url( get_permalink() ),
          esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
          $thumb
        );
    }

  }

}

Let us know how it goes.

Thanks!

That’s worked! Thanks so much, it’s incredibly helpful of you!

Glad we could help.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.