Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wp_head', 'thsp_add_google_news_keyword_meta' );
- function thsp_add_google_news_keyword_meta() {
- global $post;
- if( is_single() && in_category( 'news-category' ) ) {
- $thsp_post_tags = wp_get_post_tags( $post->ID );
- // Check if post has tags
- if ( !empty( $thsp_post_tags ) ) {
- $thsp_tags_list = '';
- foreach( $thsp_post_tags as $thsp_post_tag ) {
- $thsp_tags_list .= $thsp_post_tag->name . ', ';
- }
- // Insert the meta tag, remove comma and space at the end
- echo '<meta name="news_keywords" content="' . substr( $thsp_tags_list, 0, -2 ) . '">';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement