Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove automatic use of Featured Image in Category Archives #39

Open
joemaller opened this issue Jun 14, 2023 · 0 comments
Open

Remove automatic use of Featured Image in Category Archives #39

joemaller opened this issue Jun 14, 2023 · 0 comments
Assignees

Comments

@joemaller
Copy link
Member

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;
}

@joemaller joemaller self-assigned this Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant