Last active
October 18, 2020 13:29
-
-
Save anythinggraphic/a9184247476aaf69467b403d3e135ed4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* @link https://anythinggraphic.net/yoast-seo-add-custom-social-share-images-for-archive-category-pages-in-wordpress | |
/* Add custom Twitter Social Share images for Yoast SEO for Archive pages | |
----------------------------------------------------------------------------------------*/ | |
add_filter( 'wpseo_twitter_image', 'ag_yoast_seo_tw_share_images', 10, 1 ); | |
function ag_yoast_seo_tw_share_images( $img ) { | |
if( is_post_type_archive( 'archivename') ) { | |
$img = get_stylesheet_directory_uri().'/images/your-image-file.jpg'; | |
} | |
if( is_category( 'categoryname') ) {{ | |
$img = get_stylesheet_directory_uri().'/images/your-image-file.jpg'; | |
} | |
return $img; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment