• Welcome to the all-new Kolakube support, the official place to get help for Marketers Delight, XFtoWP, CryptoWP, and other WordPress products! Please login with your account details to access private support forums.

How do I remove featured images from the Blog page only?

andyteh

New member
Md
Messages
3
Reaction score
2
Hi everyone,

I want to remove the featured image of all posts from only the Blog page (leaving featured images visible on all other archive pages and the individual posts).

Currently, I have the position of the featured image of my posts as "Full-width, below headline", "Full-width, above headline" or inline. I don't have any featured image set as "Headline cover" or "Header cover".

I found this old thread in which the OP had a similar issue. Unfortunately, I cannot download the md-child-theme.zip file, which would have pointed me in the right direction on what code to change or add in text.php and functions.php.

I'd appreciate any help.
 
Solution
Hi @gauravtiwari,

Yes, I want to remove the featured images of posts listed on the Blog page as shown in your image.

The following image shows an example of the issue I had on my blog.

with-featured-images.PNG

These are the first four posts on the Blog page. The first and fourth posts have their featured image set to "Full-width, above headline", while the second and third posts have the featured image position hidden ("Hide image"). When the image position is "hidden," it doesn't appear on the Blog page, which is what I want. However, this becomes a problem for those posts where I want to have a featured image visible on the post page.

My interim solution was to change the position of the featured images to either "Full-width, below...

gauravtiwari

Blogger
Md
Messages
294
Reaction score
124
Website
gauravtiwari.org
Hi @andyteh , do you want to remove the blog page header background or the featured images of posts listed at that page like this →
1657911797994-jpeg.4012

I might help if you could provide me with an URL that I can look.
 

Attachments

  • 1657911797994.jpeg
    1657911797994.jpeg
    407.5 KB · Views: 21
Comment

andyteh

New member
Md
Messages
3
Reaction score
2
Hi @gauravtiwari,

Yes, I want to remove the featured images of posts listed on the Blog page as shown in your image.

The following image shows an example of the issue I had on my blog.

with-featured-images.PNG

These are the first four posts on the Blog page. The first and fourth posts have their featured image set to "Full-width, above headline", while the second and third posts have the featured image position hidden ("Hide image"). When the image position is "hidden," it doesn't appear on the Blog page, which is what I want. However, this becomes a problem for those posts where I want to have a featured image visible on the post page.

My interim solution was to change the position of the featured images to either "Full-width, below headline" or "Full-width, above headline" (since these two image positions are what I'll probably be using in the longer term, and it reduces the code I wrote). I then added the following code in functions.php.

functions.php:
/**
 * Remove featured image above headline and re-add if not on Blog page.
 */

function md_child_featured_image_above_headline() {
    $position = md_featured_image_position();
    if ( has_post_thumbnail() && $position == 'above_headline' && !is_home() )
        md_featured_image( 'above_headline', 'md-full' );
}

remove_action( 'md_hook_content_item', 'md_featured_image_above_headline', 10 );
add_action( 'md_hook_content_item', 'md_child_featured_image_above_headline', 10 );

/**
 * Remove featured image below headline and re-add if not on Blog page.
 */

function md_child_featured_image_below_headline() {
    $position = md_featured_image_position();
    if ( has_post_thumbnail() && $position == 'below_headline' && !is_home() )
        md_featured_image( 'below_headline', 'md-full' );
}

remove_action( 'md_hook_content_item', 'md_featured_image_below_headline', 30 );
add_action( 'md_hook_content_item', 'md_child_featured_image_below_headline', 30 );

I get the result I want, i.e., all featured images (below headline and above headline) are removed from the Blog page but still appear on other archive pages. I suppose I could add more code to remove inline featured images, i.e. "Right, text wrap", "Left, text wrap" and "Center, no text wrap" if required in the future.

At this point, I guess I'm asking whether I could unhook the featured image from appearing (including those whose position is set to below headline, above headline, or inline) when the posts are on the Blog page only. My interim solution above unhooks all featured images and rehooks them for posts and archive pages other than the Blog page.

Link to my blog
 
Comment
Solution
Top