1. Home
  2. Knowledge Base
  3. SEO Suite
  4. Content Analysis API – Integrate Your Theme or Plugin with Rank Math SEO

Content Analysis API – Integrate Your Theme or Plugin with Rank Math SEO

In this tutorial, you will learn how to integrate Custom fields present in your theme or plugin with the Rank Math SEO plugin.

Using this content analysis API, Rank Math will start analyzing data present in these fields.

Steps to register custom fields in Rank Math’s content analysis API:

1 Create a .js File

Create a new JS file in your Plugin or Theme and add the content analysis API related code in it. Make sure to use rank-math-post-metabox dependency.

wp_enqueue_script( 'rank-math-integration', DIR . '/js/rank-math-integration.js', array( 'rank-math-post-metabox' ), false, true ); 

2 Registering a plugin/theme

Register your theme or plugin to the Rank Math Content analysis API using below code:

 RankMathApp.registerPlugin( 'plugin-name' );

3 Filters to analyze data

Rank Math supports 2 filters to analyze title and content. Following is a syntax to add filter:

wp.hooks.addFilter( 'rank_math_title', 'plugin-name', callback_function_to_fetch_title ) // This will hook into title analysis data.
wp.hooks.addFilter( 'rank_math_content', 'plugin-name', callback_function_to_fetch_content ) // This will hook into content analysis data.

4 Function to reload the data

It is recommended to preload as little data as possible to minimize client-side memory usage. If you need to dynamically fetch more data in the process of content creation, then you can use RankMathApp.reloadPlugin( 'plugin-name' ) function to reload the content analysis. You can also use this function to reload the analysis when any custom field data is changed.

Here is the example of Content Analysis API used in WP Review plugin https://github.com/MyThemeShopTeam/WP-Review/blob/new-analysis/admin/assets/js/rank-math-integration.js

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will ge back to you.

Open Ticket

Related Articles