<?php if (is_single()) : if (have_posts() ) : while (have_posts() ) : the_post(); ?>
<meta name="description" content="<?php $tags = the_tags([
'number' => 4,
'orderby' => 'rand',
] );
if( $tags) :
foreach( $tags as $tag ) {
echo $tag->name . '. ';
}
endif; ?>"/>
<?php endwhile; endif; elseif (is_front_page()): ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>
the_tags() ничего не возвращает в переменную $tags. Более того, те аргументы которые вы передаете, функция the_tags() не принимает и игнорирует. Повторяю — читайте документацию
<?php if (is_single()) : if (have_posts() ) : while (have_posts() ) : the_post(); ?>
<meta name="description" content="<?php $tags = the_tags([
'number' => 4,
'orderby' => 'rand',
] );
if( $tags) :
foreach( $tags as $tag ) {
echo $tag->name . '. ';
}
endif; ?>"/>
<?php endwhile; endif; elseif (is_front_page()): ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>$posttags = get_the_tags();
if( $posttags ){
foreach( $posttags as $tag ){
echo $tag->name . ' ';
}
}