Site logo

Archived topic

Moving featured image below content.

5 replies · Started by Kris on March 3, 2022

Viewing posts 1–6 of 6

Hi,
I want to move the featured image from the before article to below content, but only on a specific custom post type.
No change in the code, just moving the placement to another gp hook.
I have found this: https://generatepress.com/forums/topic/decrease-the-spacing-between-the-headline-and-image/#post-1672071
But I think this is not good for my problem.

I've been digging into the code of the theme, but I'm not a developer, so my solution listed below need some help:
- I have noticed that featured image is using "page-header-image-single" class
- this class can be seen in featured-images.php, in "add_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );"

However, I'm not skilled enough to create proper remove_action, and then add_action.

Hi there,

can i see a post where you want to make this change ?

So this snippet:

add_action( 'wp', function() {
    if ( is_single() && 'your-post-type' == get_post_type() ) {
        remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
        add_action( 'generate_after_entry_content', 'generate_blog_single_featured_image', 5 );
    }
}, 55 );

Where it says your-post-type you need to update with your CPT name.

Thank you.
Works.
The only thing that I needed to change is to change "generate_before_content" to "generate_after_entry_header".

Aah yes, thats the correct hook as it image was after the entry header.
Glad to hear you got it working :)

This archived topic is closed to new replies.