我的帖子介于两个If语句之间,我该怎么办?

Currently I'm trying to filter out various things for the meta portion of my WordPress website, and I've found an issue, using the following code was working perfectly until I needed to get a bit more specific.

if (is_singular('post')) {
        $title = get_the_title ();
        print '<title>'.$title.'</title>';
        $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
        print '<meta property="og:image" content="'.$feat_image.'"/>';
        print '<meta name="description" content="" />';
    } else {
        print '<title></title>';
        print '<meta name="description" content="" />';         
} 

Note that I edited the meta descriptions above so that they're empty, just for the sake of posting on stack.

Then I wanted to start filtering based on the tags a post has, and obviously this is going to conflict with the already declared (is_singular('post')) function above.

However, I used the code below.

if ( has_tag( 'spanish' )) {
        print '<title>'.$title.'</title>';
        $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
        print '<meta property="og:image" content="'.$feat_image.'"/>';
        print '<meta name="description" content="" />';
}

And it is displaying the meta for this portion also in the category we wish for it too, how ever it's also displaying the meta description for the other function as well, what can I do stack?

This might sound simplistic, but firstly you want to document exactly what you want to happen. Maybe make yourself a flow chart or write a couple of paragraphs. Either way, you need to know from a non-code point of view first. This will enable you to answer questions like "Does a tag take precedence over a single post?" Once you know this process, move your conditions away from output to simplify the process. Something like this:

// defaults
$title = '...';
$metaDescription = '...';
$featuredImage = '...';

// overrides for difference scenarios
if (is_singular('post')) {
  // set title, etc here
}
if (has_tag('spanish')) {
  // override or concatenate title, etc here
}

// output
print "<title>$title</title>";
<!-- etc etc -->