ajaskey
Member
Posted 5 months ago #
I use the_excerpt() to create the description of individual posts.
<?php if (is_single()) {
echo (' <meta name="description" content="');
the_excerpt();
echo (' ">');
}
elseif (is_page())
...
...
Each description is enclosed in <p>...</p>. I want to remove this. Is there a function to send the output of the_excerpt through to remove html tags?
Example of output:
<meta name="description" content="<p>The Square of 90 is about to complete off the March low with price up over 40%.</p>
Thanks.
Andy
Admittedly my PHP skills are not the greatest but consider the code changes of using the PHP substr and strlen functions:
<?php if (is_single()) {
echo (' <meta name="description" content="');
substr(the_excerpt(),4,(strlen(the_excerpt)-4));
echo (' ">');
}
elseif (is_page())
Links to the PHP manual for reference, please validate code.
http://ca.php.net/substr
http://ca.php.net/manual/en/function.strlen.php
ajaskey
Member
Posted 5 months ago #
cais - Thanks for the suggestion. I found that "the_excerpt_rss()" call does exactly what I want.