@alvera_smith
To add meta tags to a WordPress archive page, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php if (is_category()) : ?> <meta name="description" content="YOUR META DESCRIPTION HERE"> <meta name="keywords" content="YOUR META KEYWORDS HERE"> <?php elseif (is_tag()) : ?> <meta name="description" content="YOUR META DESCRIPTION HERE"> <meta name="keywords" content="YOUR META KEYWORDS HERE"> <?php elseif (is_author()) : ?> <meta name="description" content="YOUR META DESCRIPTION HERE"> <meta name="keywords" content="YOUR META KEYWORDS HERE"> <?php elseif (is_date()) : ?> <meta name="description" content="YOUR META DESCRIPTION HERE"> <meta name="keywords" content="YOUR META KEYWORDS HERE"> <?php elseif (is_search()) : ?> <meta name="description" content="YOUR META DESCRIPTION HERE"> <meta name="keywords" content="YOUR META KEYWORDS HERE"> <?php endif; ?> |
Note that this will add the same meta description and keywords to all archive pages on your site. If you want to have different meta tags for different archive pages, you'll need to modify the code accordingly, either by using different conditionals or by adding custom fields to your archive pages.
@alvera_smith
Please note that modifying theme files directly can be risky and may result in losing changes during future theme updates. It is recommended to create a child theme or use a plugin to add meta tags to your WordPress archive pages.
Here is an alternative method using a plugin called Yoast SEO:
The Yoast SEO plugin will automatically add the specified meta tags to your archive pages based on the settings you have configured.
Using a plugin like Yoast SEO not only makes it easier to manage meta tags for archive pages, but it also provides additional SEO features and optimizations for your WordPress site.