schema.org/QAPage
-
Hello,
I would like to integrate schema.org/QAPage + Question + Answers using Schema plugin.
Is there a way making it happen?
Thanks
-
This really depends on how your Q&A page or site is built, so there is no quick answer to that. However, it can be done with some coding. I will try to give you a hint!
The best way to do so -I think- is to extend schema.org markup via the
schema_output
filter.So, if you have Answers saved in post meta (or comments), you will be able to query those answers and append them to the markup output.
You will need to:
1- Add the new schema.org type, which will contain the Question, and list of answers to that question (you may want to use
schema:Question
instead ofschema:QAPage
):add_filter( 'schema_wp_types', 'schema_wp_new_add_schema_type_762345655' ); /** * Add support for schema:QAPage to Schema Types options * * @since 1.0 */ function schema_wp_new_add_schema_type_762345655( $options ) { $options['QAPage'] = array ( 'label' => __('Q&A Page'), 'value' => 'QAPage' ); return $options; }
After implementing the code above, the new schema.org type will show in under Schema types in the Settings>Types meta box.
2- Create a new type and configure it within the Types section to work where your Questions are saved (example: the Q&A custom post type).
3- Create a sample page to test it out. Test the markup and see what’s missing.
4- Query data from your posts (post meta) and use it override properties in the schema.org markup output.
I hope this help you get started.
Thank you,
I am going to implement it.Great, good luck!
Step 2 isn’t entirely clear. How do I change the default WebPages @type in my new QAPage type to “Question” (as per https://developers.google.com/search/docs/data-types/qapage )?
Thanks.
@docjohn You can override the output array. Something like this:
add_filter('schema_output', 'schema_wp_extend_output_987345256'); /** * Extend / Override Schema Output * * @since 1.0 */ function schema_wp_extend_output_987345256( $schema ) { // Remove mainEntityOfPage unset($schema['mainEntityOfPage']); // Remove articleSection, since it will through an error unset($schema['articleSection']); // Add mainEntity > Question $schema['mainEntity']['@type'] = 'Question'; return $schema; }
I hope this helps.
That definitely helps get me started. Thanks for the assistance!
No problem.
Thanks for this. Are you going to and this functionality to the plugin? Meaning…. So I can do it in a friendly GUI environment.
Also. do you suggest a way to implement the speakable schema type? Is this something you planned on implementing?
I don’t know whether it would be suitable here to name other plugins, but I solved the exactly same issue today with this plugin https://wordpress.org/plugins/schema-and-structured-data-for-wp/
It supports QAPage schema type if your question-answer site is built with DW Question plugin.
In fact, I was looking for this schema support for long and thought you would find it helpful. Thanks.
https://prnt.sc/m7027w
https://prnt.sc/m703a1Hello, I want to integrate schema.org/QAPage + Questions + Answers using the plugin “Schema – All In One Schema Rich Snippets” Is there a way to make it happen? thank you
- The topic ‘schema.org/QAPage’ is closed to new replies.