[Support request] Featured image shortcode

Home Forums Support Featured image shortcode

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #715285
    gedosan

    Hi guys

    I want to control where my featured images appear in posts. I’m assuming there’s a shortcode that I can add to the post for this…I tried ‘[featured_img]’ but it didn’t pull through the image?

    Thanks
    G

    GeneratePress 2.1.4
    GP Premium 1.7.3
    #715294
    David
    Staff
    Customer Support

    Hi there,

    GP doesn’t include any shortcode functions, but here is a PHP snippet you can add for that exact shortcode:

    add_shortcode('featured_img', 'fi_in_content');
    
    function fi_in_content($atts) {
        global $post;
        return get_the_post_thumbnail($post->ID);
    }
    #716330
    gedosan

    any chance you can tweak the code so if the shortcode is detected, the page doesn’t show the featured image at top of the page.

    Basically, I want to have featured images on ALL posts but on certain posts have the featured image slightly further down the page (by placing the shortcode in the WP editor). As things stand, I get two featured images when I do this 🙂

    Thanks

    #716336
    David
    Staff
    Customer Support

    If you’re manually adding the short code then you can use the disable elements meta box to remove the templated featuered image:

    https://docs.generatepress.com/article/disable-elements-overview/

    #716351
    gedosan

    great thanks

    #716355
    David
    Staff
    Customer Support
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.