I am using Swiftype's crawler to index my WordPress site. How do I add meta tags?
If you have a WordPress site and would like to index your site with our crawler versus using Swiftype's plug-in, you have the option of adding meta tags. Meta tags allow our crawler to index posts on your site. The indexed information can be searched and filtered against, allowing for a custom search experience.You will only have to add this code to your template once, as every published post will then have the meta tags assigned without any additional code.
Step 1: Open your theme in the WordPress dashboard
Log into your WordPress dashboard and select Appearance -> Editor. From this view, you can access your current themes code.
Step 2: Open your Header file (
On the right hand side you will see all the files in your template. Find the file titled, Header or
header.php. This is the only file you will need to edit in order to add meta tags.
Step 3: Add meta tags
In the head tag of the header is where you will enter the meta tag information. The meta tags will use Swiftype's approved syntax:
<meta class="swiftype" name="[field name]" data-type="[field type]" content="[field content]" />
Here's a breakdown of the field parameters:
name can be anything you would like. You may want fields for
data-type is the type of content you will be using in the tag. There are several different acceptable data-types and you can see review them by referencing our documentation.
content is the actual information associated with the name of the tag. For example if you have a tag for author, the content would be the author of that post. This information is retrieved using a php function to extract the information from the post. The WordPress Code Reference lists all the functions you can use to access content.
Below is an example meta tag for the author of the post. This may need to be edited for your specific theme and site.
// Author of the Post
<meta class="swiftype" name="name" data-type="string" content="<?php echo get_the_author_meta('email', $post->post_author); ?>">