Site logo

Archived topic

Featured image parameter

22 replies · Started by Charles on January 7, 2022

Viewing posts 1–15 of 23

Adjusting single blog page parameters in the customizer changes name and date but does not change any featured image aspects. Thanks.

Hi there,

i think theres some crossed wires - looking at the post your provided - there is no featured image being displayed. Only images that are within the content of the post. The size of those images are defined when they are added to the post content its not something the theme controls.

Yes, it's input as a featured image:

featured image

But I do have this PHP to move it to after the 2nd paragraph:

add_filter( 'the_content', 'insert_featured_image', 20 );
function insert_featured_image( $content ) {
$feat_img = get_the_post_thumbnail($post->ID, 'post-single');
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $feat_img, 2, $content );
}
return $content;
}
// Parent Function that makes the magic happen
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = '</p>';
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {
if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}
if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}
return implode( '', $paragraphs );
}

And then I must be turning off the featured image itself somewhere else.

I guess it's not just moving the featured image it's making a separate image using the featured image thumbnail?

What happens if you remove the functions for now?

The featured image is at the top of the page and follows the sizing from the customizer blog page parameters as it should.

But I'd still like it to appear after the 2nd paragraph...

This archived topic is closed to new replies.