because is_archive
is earlier so it doesn’t evaluate the others, it’s checked from the top down and since is_archive
is super generic it will be true
for all archives, categories, tags, dates, etc etc. You need to go from the most specific to the least specific, not the other way around.
Think of it like this:
if(is_food()): echo 'food';
elseif(is_meat()): echo 'meat';
elseif(is_chicken()): echo 'chicken';
else: ....
endif;
Anything that’s food will be true, so it will print food
. It will only check is_meat
if it’s not food, but since is_food
is always true when is_meat
is true, it will never be checked.
Instead this would work better:
if(is_chicken()): echo 'chicken';
elseif(is_meat()): echo 'meat';
elseif(is_food()): echo 'food';
else: ....
endif;
Always go from the most specific/rare/unique first, and the most generic/general last.
Note that it’s not ideal to do this in the theme template though, WordPress has hooks and APIs for generating the title tags already, and you should work with this system rather than preventing it from working with hardcoded title tags