Shortcode to remove featured image from posts

Home Forums Icelander Shortcode to remove featured image from posts

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22013
    excaltech
    Participant

    Shortcode to remove featured image from posts

    Resolved

    Hey there! Have you noticed this support service is provided FREE of charge?
    If you like the speed and accuracy of resolutions, please consider supporting me with a small donation. Thank you

    Consider a donation →

    Hi Oliver,

    I was just wondering if there is a filter in Icelander that I can use to remove the featured image from individual posts. I have a custom function I can take from another site to make it display inline with the post content, but I’m looking for a way to actually remove it as a full-width image. I know I could hide it with CSS, but I hate doing that as I consider it a bit of a dirty solution.

    Thanks!
    Ben

    #22015
    Oliver Juhas
    Keymaster

    Hi Ben,

    Actually, you can remove the intro section media (image) per post/page basis using custom fields too (specifically with no_intro_media and for your convenience the theme fully integrates this with Advanced Custom Fields plugin as described in theme documentation I’ve linked to).

    Alternatively, you can remove the intro media with PHP code in your child theme‘s functions.php file, if you prefer. This should do the trick (please adapt to your needs):

    function child_theme_setup {
    	if ( is_single() ) {
    		remove_action( 'wmhook_icelander_intro_before', 'Icelander_Intro::media' );
    	}
    }
    add_action( 'after_setup_theme', 'child_theme_setup', 100 );

    Best regards,

    Oliver Juhas
    WebMan Design

    #22016
    excaltech
    Participant

    Thank you, Oliver. I used the functions.php shortcode you provided. I couldn’t get it to work with the “if ( is_single())” statement (I also tried “is_singular(‘post’)”), but I just commented it out and confirmed that it doesn’t impact any other pages on the site, so it’s working as expected.

    #22017
    Oliver Juhas
    Keymaster

    Hi Ben,

    By commenting out the if conditional statement you are actually effectively removing the intro media on whole website. If this is what you aim for, then I’m glad the code works for you :)

    Tip: Please note that this is not a shortcode, actually :) This is pure PHP code. A shortcode is something different in WordPress.

    Best regards,

    Oliver Juhas
    WebMan Design

    #22019
    excaltech
    Participant

    Hi Oliver,

    I’m not using intro media / featured image anywhere on the site, so it’s no problem in this case.

    Oops, I did say shortcode didn’t I! Yes, I understand that it’s a PHP function rather than a WordPress shortcode, but I appreciate you pointing that out. It’s really great that you take the time to educate your customers as that’s something that not many developers bother to do.

    Thanks again,
    Ben

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.