How To Add Keywords To WordPress Theme Using Tags

Log into Admin panel
On the left-hand navigation menu, navigate to Appearance>Editor
On the right-hand side, find the header.php file
Locate the Title tag
Place the following code just below the title:

<meta name="keywords" content="<?php
$posttags = get_the_tags();
if ($posttags) {
  foreach($posttags as $tag) {
    echo $tag->name . ', '; 
  }
}
?>how to" />

I placed a generic tag “how to” at the end to avoid trailing my keywords with a lonely comma. My blog is mostly a How-To so it’s appropriate.

Then, press the “Update File” button.

To see the changes, view your post. Once it’s open, go to the Tools section in your browser and select View Source.

Your header area should display your keywords below your title area as such:

<meta name="keywords" content="add, function, keywords, tags, theme, wordpress, how to" />
Posted in PHP, SEO, Web Development, WordPress and tagged , , , , , , , , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *


*