How to add meta tags to a WordPress archive page?

by alvera_smith , in category: SEO , 10 months ago

How to add meta tags to a WordPress archive page?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by mabelle , 10 months ago

@alvera_smith 

To add meta tags to a WordPress archive page, you can follow these steps:

  1. Login to your WordPress dashboard.
  2. Go to Appearance > Theme Editor.
  3. Find the file archive.php or category.php in the right-hand panel (this will depend on the type of archive page you want to add meta tags to).
  4. Add the following code to the head section of the archive.php or category.php file:
 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; ?>


  1. Replace "YOUR META DESCRIPTION HERE" and "YOUR META KEYWORDS HERE" with the actual description and keywords you want to use for your archive page.
  2. Click the "Update File" button to save the changes.


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.