赛派号

平价好用的唇部护理 Rank Math Content Analysis API for Theme & Plugin Developers

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 wp-hooks and rank-math-analyzer dependency.

wp_enqueue_script( 'rank-math-integration', DIR . '/js/rank-math-integration.js', [ 'wp-hooks', 'rank-math-analyzer' ], false, true ); 2 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', 'rank-math', this.getContent ) // This will hook into content analysis data. 3 Function to reload the data rankMathEditor.refresh( 'title' ) – To reload the Title tests.rankMathEditor.refresh( 'content' ) – To reload the Content tests.

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 code that can be used to include WP Custom Fields data in Rank Math鈥檚 Content analysis https://github.com/rankmath/seo-by-rank-math/blob/master/assets/admin/src/custom-fields.js

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了