Struggling with schema

#130173
  • Resolved quizzical
    Rank Math business

    Hi Support:

    Trying to figure out if I can use RankMath or RankMath Pro – or if I need to keep looking. I have been working on schemas for the last couple of days, but run into problems. I am not sure how much difficulty is due to my ignorance and how much is due to limitations of the product.

    I use an excellent directory theme (My Listing). At the moment I am concerned with how to create the best search results for each of the listings provided by the site’s customers. The My Listing theme creates a schema (or multiple schemas, for example, “local business” and “service”) for each customer listing within my several Listing Types. Those Listing Types include business products, services, events, jobs, etc. Of course events utilize different structured data than services. The schema for each listing is generated with variables from the directory listing data provided by the client/listing creator.

    1. The schema properties and values do not seem to flow through from the schema created by my theme to the webpage source code generated by RankMath. I am able to identify/classify many structured data fields for each listing, but this does not seem to get passed along to the schema in the page html. Why is that? Does RankMath integrate with schemas created by themes? Is it limited to a single schema? What should I do to ensure that all structured data is present in the html schema code?

    2. RankMath creates a single Post Type (custom post type), “Listings,” for the half-dozen Listing Types mentioned above (services, events, jobs, etc.). I cannot figure out how to apply different schema data to each of these different listing types. The theme permits adding multiple schema types for each Listing Type. How do I ensure that the variety of Listing Types and their different types of data are included in the schema code placed in the page html by RankMath?

    3. I am trying to modify the schema title for the “Listings” Custom Post Type. I do not seem to be able to customize the “single listing title” using %customfield(field-name)%. Does this require the ACF plugin? Will installing the ACF plugin make accessible the custom fields previously created in the theme? Or does it require recreating fields from scratch? For example, I can use %title% for the name of the service provided, and I would like to add the company name or brand name using %customfield(company-name)% – where “company-name” is a custom field in the theme, or %customfield(brand)% – where “brand” is a property of the Service Schema type. What is necessary to do something like that?

    Finally, what am I missing? Am I not understanding the concept? Or is RankMath limited in some important ways for my use case?

    My apology for my lack of understanding. I appreciate whatever insight/direction you can provide.

    Kind regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for getting in touch with us.

    Rank math Pro has a long list of features that are not available in the free version or are more advanced, you can check the following comparison: https://rankmath.com/pricing/#comparison

    1. If your theme is adding schema for these post types, you should disable the Schema module in Rank math dashboard to avoid any conflicts. If you want to use Rank math schema instead, you will need to check with the theme support to help you in disabling the schema added through the theme and then you can implement Rank math schema.

    2. Schema markup can be added for individual post types either globally by defining a default schema( this will take effect on new posts) or on each of the posts under the schema tab. You can add multiple schema to individual posts in the Pro version. Here is a guide for reference: https://rankmath.com/kb/rich-snippets/

    3. Could you please check if you are able to enable the ACF module in Rank math dashboard ? If it asks you to activate an ACF plugin, it means the custom fields generated by your theme aren’t being recognized by Rank math. If you were to install the ACF plugin, Rank math would look for the ACF plugin related fields, not the CFs by your theme. You can add it and transfer your data to ACF fields.

    Another way to achieve using defined variables for from your custom fields would be to define extra variables that get the data from the custom fields using this filter: https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-variables then use these variables instead.

    We are here to assist and if there is anything you feel you are missing or not understanding any part. If you want you can share screencast using a tool such as https://www.loom.com or screenshot using https://imgbb.com

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    quizzical
    Rank Math business

    Thank you Michael for your informative response. It helped me to find the error – which was mine. Of course.

    1. I disabled the schema in RankMath. That forced me to look further into the code to find where was the schema from my theme. I realized that it was near the end of the html, and that it was still there when I re-enabled schema in RankMath. So the first error seems to be my own. I will leave both enabled since there does not seem to be a conflict after all.

    2. I will set a schema for the other post types within RankMath. Thank you for the link to the guide for Pro.

    3. I did not check to enable the ACF module since this now seems unnecessary.

    Related Question:

    4. This site also has a) a page which aggregates RSS feeds from multiple sources, and b) a page which contains a Q&A forum. Is there anything special I should do to enable a schema for each of those pages? At present RankMath does not show either of those items as its own post type in the schema module.

    quizzical
    Rank Math business

    A follow up question regarding “adding extra variables in the RankMath dropdown.” I think this will work for me, but I have questions about what needs to be replaced in the code. I have not been able to get it to call the variable value from the theme. What am I missing?

    Here are my questions to the code below.
    1. I change ‘custom_variable_slug’ to the name of the custom field (i.e. ‘company-name’) that I use in my theme. Correct?
    2. I change ‘Custom variable name.’ to whatever name (i.e. ‘Company name’ I choose to give this for the purpose of this snippet. Correct?
    3. I change ‘Custom variable description.’ to whatever description (i.e. Company or brand name.’) that I choose for the purpose of this snippet. Correct?
    4. What do I do with ‘custom_variable_callback()’? Do I change the name to ‘company-name-callback()’ or something like that? I am not clear about this last step.
    5. There are no other changes to be made. Is that correct?
    6. I am placing this snippet in the functions.php file. Is that correct?

    Here is the original code description:

    /**
     * Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
     */add_action( 'rank_math/vars/register_extra_replacements', function(){
     rank_math_register_var_replacement(
     'custom_variable_slug',
     [
     'name'        => esc_html__( 'Custom variable name.', 'rank-math' ),
     'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
     'variable'    => 'custom_variable_slug',
     'example'     => 'custom_variable_callback()',
     ],
     'custom_variable_callback()'
     );
    });

    Here is the revision that I am making:

    /**
     * Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
     */add_action( 'rank_math/vars/register_extra_replacements', function(){
     rank_math_register_var_replacement(
     'company-name',
     [
     'name'        => esc_html__( 'Company name.', 'rank-math' ),
     'description' => esc_html__( 'Company or brand name.', 'rank-math' ),
     'variable'    => 'company-name',
     'example'     => 'company-name-callback()',
     ],
     'company-name-callback()'
     );
    });

    What have I done wrong with this?

    Thank you

    Hello,

    Thank you for the follow up.

    4 ( a & b). Are the pages listed in your WordPress dashboard > Pages ? If they are, then you can easily change their schema under the schema tab: https://i.rankmath.com/guHVym

    As for the filter to add extra variables, we do not offer code customization. Your code however seems to be missing the callback function. I can suggest that you check how it was done in this thread, for a different situation though: https://support.rankmath.com/ticket/add-new-veriable-for-titles-and-description/?view=all

    Hope this helps you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘Struggling with schema’ is closed to new replies.