Last active
April 7, 2022 19:27
-
-
Save ms-studio/1628192 to your computer and use it in GitHub Desktop.
WordPress meta description tag
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 // ** DESCRIPTION v.0.2 ** | |
if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); | |
?><meta name="description" content="<?php | |
$descr = get_the_excerpt(); | |
$text = str_replace( "\r\n", ', ', trim($descr) ); | |
echo esc_attr($text); | |
?>" /> | |
<?php endwhile; endif; elseif(is_home()) : | |
?><meta name="description" content="<?php bloginfo('description'); ?>" /> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
another method:
http://www.texto.de/the_excerpt-ohne-anfuehrungszeichen-und-shortcodes-1770/
echo htmlentities(strip_tags(get_the_excerpt()));