• Resolved cnotv

    (@cnotv)


    Is there any way and form to add extra markup, which theoretically should be included, such as aggregateRating?
    https://schema.org/aggregateRating

    I’m actually forced to hack the plugin locally, but I gues it should have already a JSON like:

    
        $json['aggregateRating'] = [
          '@type' => 'AggregateRating',
          'ratingValue' =>  '',
          'reviewCount' =>  ''
        ];
    

    This should be added to the option in the dashboard, otherwise would make not so much sense just for header/body/author

    • This topic was modified 7 years, 5 months ago by cnotv.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Hesham Zebida

    (@hishaman)

    Yes indeed, so you aren’t forced to hack the plugin in any way, you can do this:

    add_filter( 'schema_wp_types', 'schema_wp_new_add_schema_type_7623456' );
    /**
     * Add New type to Schema Types options
     *
     * @since 1.0
     */
    function schema_wp_new_add_schema_type_7623456( $options ) {
    	
    	// Change 'NewType' to the actual schema.org type you want to add
    	// Example: Event, Product, JobPosting, ...etc.
    	$options['NewType'] =  array ( 
    					'label' => __('NewType'),
    					'value'	=> 'NewType'
    				);	
    	return $options;
    }

    Here is a link to the code gist.

    But, it’s not as simple as adding just the new type, you will have add other properties as well to finally output a valid schema markup.

    I suggest you look at the free Schema Review plugin, it will give you an idea of how you can achieve this by walking through its code.

    • This reply was modified 7 years, 5 months ago by Hesham Zebida. Reason: adding link to code gist
    Thread Starter cnotv

    (@cnotv)

    Thank you for the answer!

    However noo, the idea is to keep exactly the same type and just extend it with the rating.
    As you can see the generic Article itself allows a sequence of options, one of those is aggregateRating:
    https://schema.org/Article

    So instead of the Article Type, I just want to use the options of the meta box.
    Even better would be to just point a meta key without the need of an input.
    This is the option I mean:

    View post on imgur.com

    Do you think is this possible? Or otherwise use an hook in the same way to extend the object for Article – Type General?

    Thank you in advance!

    • This reply was modified 7 years, 5 months ago by cnotv.
    Plugin Author Hesham Zebida

    (@hishaman)

    Yes of course, you can keep the same type and extend it with rating or reviews, so yes this is absolutely possible.

    However, in your code example, I see you’ve chosen type AggregateRating, which has a “reviewCount“, which leaded me to think you will need to introduce a new schema.org type for it. I am not sure if this is what you want to do since the aggregate rating should have real user reviews published on the page.

    You may look at using “reviewRating” instead of “AggregateRating” in case the latest doesn’t work, or gives you errors.

    I hope this was useful.

    Thread Starter cnotv

    (@cnotv)

    Yeah I agree would make no sense a rating without an actual review, but unfortunately the request is to stick just to votes, which is something already online in another CMS.

    Thread Starter cnotv

    (@cnotv)

    I’ve been digging more into the snippets of code to alter the plugin without hack it and I found probably what I need, since match with the same place I’m writing the code.
    https://gist.github.com/schemapress/abf19698e702da7f27787d9bcb033e53

    A second part of the code is already written in another plugin where AJAX the rating is handled, with final meta data update, so it will synchronize with the whole project.

    I’ll give a try and let you know, thank you for the support, snippet and plugin ??

    Plugin Author Hesham Zebida

    (@hishaman)

    Fantastic!

    Let me know if you see a need for additional filters in the core code. I will be glad to add them in the Schema plugin to make things easier.

    Thread Starter cnotv

    (@cnotv)

    Perfect all solved without hack!
    Thank you for the support ??

    Plugin Author Hesham Zebida

    (@hishaman)

    Glad to hear that ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add aggregateRating’ is closed to new replies.