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?