Using Anspress with Rank Math Pro (Schema.org)
-
Hi, I’ve tried to use the site to ask a question, but the registration’s process don’t work. I’m using currently Rank Math Pro and I want to use the “question” of Schema.org. And the built-in schema of Anspress don’t work anymore (a update to use Json will be welcome).
And Rank Math Pro answered me that Anspress is not compatible with their pluging, but I can add variables from Andpress with some codes. I want to know how to implement that. Below is the answer :
Anspress isn’t compatible with Rank Math so this may require coding it in PHP. Specifically, you need to retrieve the data from the Q&A item of Anspress (you may contact the support team from Anspress for this) and assign it to a custom Rank Math variable. Here’s a sample code to create a custom variable with Rank Math: add_action( 'rank_math/vars/register_extra_replacements', function(){ rank_math_register_var_replacement( 'shortcode_var_name', [ 'name' => esc_html__( 'Author name', 'rank-math' ), 'description' => esc_html__( 'Author description', 'rank-math' ), 'variable' => 'shortcode_var_name', /* the actual variable: %shortcode_var_name% */ 'example' => shortcode_var_name_call_back(), ], 'shortcode_var_name_call_back' ); }); function shortcode_var_name_call_back(){ return "field value here..."; } You can then insert the variable %shortcode_var_name% to the schema structure. If Anspress is using a standard custom field, you can make use of this variable instead: https://rankmath.com/kb/variables-in-seo-title-description/#num-39-custom-field-advanced
- The topic ‘Using Anspress with Rank Math Pro (Schema.org)’ is closed to new replies.