Creating the Difference

Create variables for Yoast SEO

Posted on: 15-11-2018 Last modified: 03-07-2021
Categories: HTML, PHP, Snippets Tags: , ,

The Yoast plugin is one of the most popular SEO plugins for WordPress out there. It is easy to use and helps you to optimise your website for search engines like Google.

By default Yoast offers several variables to make things easier. Those are indicated by %%, for example:
Using %%title%% will fetch the post title, without you having to type it in. :-)

Here is a list of currently built-in Yoast variables.

How to create Events Manager variables for Yoast SEO?

As you can see in the link above, Yoast offers serveral variables, but (of course) none apply to the awesome Events Manager plugin. Those you would have to create yourself.

Step 1: Create Yoast Variables.

First, you need to decide what Event info you would like to include in the Yoast SEO snippet box. For this example we will add variables to show the event start date, event start time, event location name and the event category. I think these are the most commonly used in event descriptions and excerpts.
Add this to your functions.php:Click here to learn how to safely add your code to WordPress.

Of course, you can add as many variables as you need.

Step 2: Use the variables in the Yoast snippet box.

You can now use these variables, like %%event_name%%.

Please note: Unlike native Yoast variables, these custom variables will not be processed in the back-end preview. They will however show the correct end-result on the page. You can check that by looking at the page’s source code.

⇐ Previous
Next ⇒