Код: Выделить всё
function wcs_add_meta_keywords() {
global $post;
if ( is_single() ) {
$cats = get_the_category( $post->ID );
$tags = get_the_tags( $post->ID );
$keywords = '';
foreach ( $cats as $cat ) {
$keywords .= $cat->cat_name . ", ";
}
foreach ( $tags as $tag ) {
$keywords .= $tag->name . ", ";
}
echo '' . "\n";
}}add_action( 'wp_head', 'wcs_add_meta_keywords' , 2 );
Код: Выделить всё
function wcs_add_meta_description_tag() {
global $post;
if ( is_single() ) {
$meta = strip_tags( $post->post_content );
$meta = strip_shortcodes( $post->post_content );
$meta = str_replace( array("\n", "\r", "\t"), ' ', $meta );
$meta = mb_substr( $meta, 0, 125, 'utf8' );
echo '' . "\n";
}}add_action( 'wp_head', 'wcs_add_meta_description_tag' , 2 );
Кто-нибудь может помочь с правильным использованием переменных для обоих кодов.
заранее спасибо
Подробнее здесь: https://stackoverflow.com/questions/619 ... oocommerce