The excellent Yoast SEO plugin is adding some unwanted meta tags.
For example, I would like article:author
to appear on posts, but not on pages or other content types.
Is there a way to adjust this globally?
I’m happy to edit functions.php
, but I’m just unsure what I should be hooking in to.
I would be grateful for any pointers from those more familiar with the plugin.
I tried this:
function wpseo_show_article_author_only_on_posts() {
if ( !is_single() ) {
return false;
}
}
add_filter( 'xxxxxx', 'wpseo_show_article_author_only_on_posts' );
I need to know what hook should replace xxxxxx
.
2
Answers
You’re looking for the
wpseo_opengraph_author_facebook
filter, which ties into thearticle_author_facebook()
method infrontend/class-opengraph.php
of the plugin.The
article_author_facebook()
method does a check foris_singular()
, which checks that we’re viewing single page, post or attachment:The additional filter for
( ! is_single() )
ensures thatarticle:author
is only added to posts.If people are looking for a way to remove more yoast SEO tags, just lookup the file wordpress-seo/frontend/class-opengraph.php, and you can see which filters you can hook into to remove certain tags.
This is the code I use to remove these tags from pages: url, image, title, description and type: