Header.php dosyasında açıklama bölümü için sizce aşağıdaki kodlardan hangisi daha verimli ve sorunsuz olur

İki kodda çalışıyor tahminimce en kısa olan daha iyidir


<?if (is_home()){
    $description = " ";
} elseif (is_single()){
    if ($post->post_excerpt) {
        $description     = $post->post_excerpt;
    } else {
        $description = substr(strip_tags($post->post_content),0,150);
    }
}
?>


<meta name="description" content="<?=$description?>" />


İkinci kod

<meta name="description" content="<?php if (is_single() ) {?>
<?php if ( $posts ) : ?>
<?php function getWords($text, $limit) {
$array = explode(" ", $text, $limit +1);
if(count($array) > $limit) {
unset($array[$limit]);
}
return implode(" ", $array); }
?>
<?php foreach ( $posts as $post ) : ?>
<?php $mycontent = strip_tags($post->post_content);
$excerpt = getWords($mycontent, 19);
$a_title = $excerpt . " ."; ?><?php echo $a_title ?>
<?php endforeach // $posts as $post ?>
<?php endif // $posts ?>
<?php
$post = $this_post;
unset($this_post);
}?> " />