-
Hi,
I have two articles types on my site: (1) Article and (2) Recipes. This is my site:
https://thehealthytreehouse.com/How can I auto-set the schema by WP category, which in my case would be Category Recipe = Recipe Schema and all other categories = Article?
Thanks!
-
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Unfortunately, it’s not possible to generate the schema data on the fly by category. And also, you’ll end up getting errors in the Google Search Console for missing values in the Recipe Schema. That’s the reason we use the default schema from Settings only when it is set to Article.
Please let us know if you need our help with anything else.
Thank you.
Hi So, to make sure I am clear. Are you saying that I can only set one schema per site?
I did not understand your comment about “on the fly”. It seems like I should be able to pre-define a few schema types and then choose which schema type to use for which article or by which category.
Can you tell me if this is in your development backlog?
Thanks!
Looking through your documentation, it looks like I can select which schema to apply to the post/page:
https://rankmath.com/kb/rich-snippets/For recipes, for example, it looks like you have fairly extensive support. How can I pipe my existing data into your existing schema so Google can pick this data up more easily? It is not practical to manually enter this.
Thanks!
——— these are the fields I see for recipes in your documentation —
Headline
This is the meta-headline that the search engines (and hopefully humans) would read. Write a headline that has the name of your dish, and make it attractive so that users are bound to click it. You can use variables to pull in the title of your post and other metadata.Review Location
Google requires the review information from Schema to be shown on the page, not just the metadata. This option lets you pick where you want Rank Math to place that information. You can also choose a custom location using the shortcode option.Shortcode
If you choose the shortcode option in the setting above, you will have to paste the shortcode from this field on your page at the location where you want the review information to appear.Description
Here, you describe the dish. Obviously, you want the description to be as enticing as possible, so all the people reading it are tempted to click it. You can reference your post metadata using variables to make a dynamic description.Preparation Time
How much time does it take to prepare before cooking the dish? Enter the time here in ISO 8601 format.Cooking Time
How much time does the dish take to cook completely? Enter the time here in ISO 8601 format.Total Time
Prep time + cooking time = total time. Enter the time here in ISO 8601 format.Type
Are you cooking an entree, main course, dessert, or a salad? Enter the type here.Cuisine
Which cuisine are you cooking? Mexican, Indian, Thai, Egyptian, or something else? Enter that here.Keywords
Enter comma-separated keywords that describe your dish closely. Think of how you would add hashtags to an Instagram post.Recipe Yield
How much food does this recipe produce? Portions, grams, feed x people? Enter it here.Calories
How many calories does the dish have? Enter it here, if you know it correctly.Recipe Ingredients
Here you will enter the ingredients that you used to create the recipe. Since this is an important thing to consider for the end-user, you have to create entries for each ingredient that you use by clicking the Add Property button.Add Recipe Ingredients In Rank Math
You can add as many entries as you like. Just make to write just the name of the ingredient, and only 1 per entry, something like this.Recipe Ingridients Options
Rating
How would you rate the dish? Enter the number here.Rating Minimum
What is the minimum score on your rating scale? Enter the number here.Rating Maximum
What is the maximum score on your rating scale? Enter the number here.The next few settings are specific to a video that shows the recipe in action. Although it is optional, adding video information to your Schema will make it much more powerful and likely to be ranked. So, try to fill in all the information in the video section.
Video > Name
Enter the name of the video showing the recipe.Description
Here you can describe the video and the recipe.Video URL
Enter the URL where users can find and watch the video.Content URL
Enter the path to the actual video file here.Recipe Video Thumbnail
Enter the URL of the thumbnail that you’d like to use for the video.Auto populating these fields seems possible:
https://support.rankmath.com/ticket/auto-fill-schema-fields-for-custom-post-type/Where can I find documentation for how to do this? Thanks!
Hello, checking in again….
Is there a way to define schema from within the page or post?
Also, how can I pipe in my meta data into your rich snippet functionality? for example, for recipes, how can I pipe in my meta data of “Under 1 hour” into your rich snippet field for “Total Time”?
Thanks,
MikeHello,
The option to Auto populate is a custom option and there is therefore no documentation on the same. We do not offer custom code options but we can provide some guidance on how to customize. In your case you can use the following filter to modify the recipe schema added by Rank math and assign entity values to your custom values:
/** * Filter to change the schema data. * Replace $schema_type with schema name like article, review, etc. * @param array $entity Snippet Data * @return array */ add_filter( "rank_math/snippet/rich_snippet_recipe_entity", function( $entity ) { $entity['totalTime'] = get_post_meta( POST_ID, '_custom_field_key', true ); return $entity; }, 99 );
You can customize the filter and add it to your theme functions.php
Hope this helps you. Thank 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.
The ticket ‘Setting Schema by Category’ is closed to new replies.