Yoast SEO comes featured with a powerful set of tools to not only help you improve your SEO, but to also help you write better texts by analyzing the content of the post or page that you're working on.
In some cases, plugin developers might want to add some extra data to the analysis, which they consider to be of added importance for their overall Readability and SEO score. Yoast SEO allows for this kind of extending of the analysis.
This is also useful for plugins which add page content in ways which our plugin(s) may not natively detect (such as via custom data structures, functions and shortcodes), which they wish us to include in our analysis.
Creating the plugin
The first thing to do, is create a file in your own plugin's
js/ directory (i.e.
In this file, you'll have to ensure that, at a minimum, the following is present:
The above code adds an additional text of "Hello, I'm some additional data!" to the text analysis, but you're not limited to just sending hard-coded strings to your custom plugin. For example, you could add a custom input field and read its contents.
Registering the plugin with WordPress
Assuming you have a plugin file present (i.e.
MyCustomPlugin.php), your file might look a little something like this:
Test the code
The last step is to test the code. Make sure your plugin is properly loaded and create a new post. As a test, you could set your keyword to be the word 'additional' and see that the SEO analysis properly detects it under the 'Keyprashe in introduction' result.