Created
June 23, 2021 15:48
-
-
Save wbxpress/bb3074b3d997a797f3a028bb5ac7daf2 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
/** Add meta for SEO **/ | |
function wbxpress_add_meta_tags() { | |
// homepage | |
if (is_home()) { | |
echo '<meta name="description" content="' . get_bloginfo( "description" ) . '" />' . "\n"; | |
} | |
// single post page | |
if ( is_singular() ) { | |
global $post; | |
$meta_description = strip_tags($post->post_excerpt); | |
echo '<meta name="description" content="' . $meta_description . '" />' . "\n"; | |
} | |
// category page | |
if ( is_category() ) { | |
$meta_description = strip_tags(category_description()); | |
echo '<meta name="description" content="' . $meta_description . '" />' . "\n"; | |
} | |
// tags page | |
if ( is_tag() ) { | |
$meta_description = strip_tags(tag_description()); | |
echo '<meta name="description" content="' . $meta_description . '" />' . "\n"; | |
} | |
} | |
add_action( 'wp_head', 'wbxpress_add_meta_tags'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment