Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Support request] Suggestion Page header for pages & posts

Home Forums Support Suggestion Page header for pages & posts

Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #347978
    Tom
    Lead Developer
    Lead Developer

    Yes, if you’re using a global page header for all single posts, you won’t be able to use only the featured image inside one of your posts. The featured images are used in the global page header. In this case, you would need to use custom code to insert the featured image (not a big deal).

    Your code to add the featured image would look something like this:

    add_action( 'generate_before_content', 'tu_add_featured_image' );
    function tu_add_featured_image() {
        if ( is_singular( 'post' ) && has_post_thumbnail() ) {
            the_post_thumbnail();
        }
    }
    #348636
    Codebastler

    Yep, added that code and now the featured image shows up under the page header.
    http://playground.codebastler.com/first-test-post-with-gp-premium-1-4-alpha/

    So as a beta-tester some last thoughts:

    – I am using WP since 6 years. For me the featured image was always perceived as part of the content and not so much of the header. Especially when there were galleries, then it was the the most important pic to select as featured image. which will then be used in category & tagged pages.

    -Maybe it should be more clarified with the new page header part, what is for pages & posts globally and what is singularly.
    For example I can click “featured image”in the page header part and it is not really obvious, that it is only THAT featured image, that will be used globally. In the beginning of testing I assumed, that it WILL BE the featured image of each page or post.

    – Eventually one can add a select field in the page header part for pages & posts > “use featured image globally/singularly” – and if singularly then the custom code from you will be hooked.

    Cheers
    P.

    #349237
    Tom
    Lead Developer
    Lead Developer

    Thank you! I really appreciate your feedback and suggestions! ๐Ÿ™‚

    #382153
    Chad Biggs

    Using a shortcode is another option. You can make this a plugin or add it to your functions.

    add_shortcode('thumbnail', 'thumbnail_in_content');
    
    function thumbnail_in_content($atts) {
        global $post;
    
        return get_the_post_thumbnail($post->ID);
    }

    And then use [thumbnail] to call the image.

    #382387
    Tom
    Lead Developer
    Lead Developer

    Thanks, Chad. Good solution ๐Ÿ™‚

    #601000
    Kevin

    Can this be added via GP Hooks?

    #601056
    Kevin

    Well, answered my own question. I was able to use it in GP Hooks, but had to wrap it with the <?php ?>.

    One thing I noticed was that this makes the Customize > Layout > Blog: Feature Image: Single Post settings irrelevant.

    Also, you have to place the code in the GP Hooks block where you want the featured image to be displayed.

    Edit:: Found this did not work when I tried using it in the “After Entry Title” section in GP Hooks. How would I be able to use it there?

    #601227
    Leo
    Staff
    Customer Support

    Sorry..what exactly are you trying to do?

    Feel free to open a new topic ๐Ÿ™‚

    #601228
    Kevin

    Sorry, I was asking about using the code from Tom above in GP Hooks to add the Featured Image to the post when you are using the Header module. I guess I should have started with that in my post.

    From the searching I did, this topic had the easiest solution to implement.

    #601229
    Leo
    Staff
    Customer Support
    #601234
    Kevin

    That’s what I used. I was actually asking if that code snippet could be used with GP Hooks, and how.

    This is what I found:

    Well, answered my own question. I was able to use it in GP Hooks, but had to wrap it with the <?php ?>.

    One thing I noticed was that this makes the Customize > Layout > Blog: Feature Image: Single Post settings irrelevant.

    Also, you have to place the code in the GP Hooks block where you want the featured image to be displayed.

    Edit:: Found this did not work when I tried using it in the โ€œAfter Entry Titleโ€ section in GP Hooks. How would I be able to use it there?

    Is there a better way than this?

    #601243
    Leo
    Staff
    Customer Support

    Try this snippet:

    add_action( 'generate_after_entry_title', 'tu_add_featured_image' );
    function tu_add_featured_image() {
        if ( is_singular( 'post' ) && has_post_thumbnail() ) {
            the_post_thumbnail();
        }
    }
    #601244
    Kevin

    Thanks!

    #601604
    Leo
    Staff
    Customer Support
    #1000604
    antoine

    Hello,

    Could you tell me what is the best way to insert this code and cusomize featured image.

    add_action( ‘generate_before_content’, ‘tu_add_featured_image’ );
    function tu_add_featured_image() {
    if ( is_singular( ‘post’ ) && has_post_thumbnail() ) {
    the_post_thumbnail();
    }
    }

    Do I need to install Code Snippets?

    Thank youn

Viewing 15 posts - 16 through 30 (of 31 total)
  • You must be logged in to reply to this topic.