Skip to content

Remove automatic use of Featured Image in Category Archives #39

@joemaller

Description

@joemaller

It's a mistake to have this in here. Should be done more explicitly somewhere else. Needs to be deprecated to be sure removing it doesn't break anything.

add_filter('the_seo_framework_og_image_args', [$this, 'useFeaturedImage']);

public function useFeaturedImage($args)
{
global $wp_query;
if (is_archive()) {
foreach ($wp_query->posts as $post) {
if (has_post_thumbnail($post->ID)) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
$args['image'] = wp_get_attachment_image_src($thumbnail_id, [1000, 1000])[0];
break;
}
}
}
return $args;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions