Example: Customizing Schema for Web Tool Pages

If you’re using the Init Review System plugin to allow users to rate web-based tools built with a custom template, you can override the default schema type (usually Article or CreativeWork) and switch it to WebApplication. This helps search engines better understand your content and improves SEO visibility for web apps.

Example: Customizing Schema for Web Tool Pages

Requirements

  • The page must use a template with the slug template-tools.php
  • The schema should be changed to WebApplication and enriched with relevant metadata

1. Change the Schema Type Using init_plugin_suite_review_system_schema_type

The following code checks if the post type is page and whether the page template is template-tools.php. If both conditions are met, it switches the schema type to WebApplication.

add_filter( 'init_plugin_suite_review_system_schema_type', function( $type, $post_type ) {
    $post_id = get_the_ID();

    if ( 'page' === $post_type && get_page_template_slug( $post_id ) === 'template-tools.php' ) {
        return 'WebApplication';
    }

    return $type;
}, 10, 2 );

2. Extend the Schema Data Using init_plugin_suite_review_system_schema_data

Once the schema type is changed to WebApplication, you can enrich the JSON-LD with fields like applicationCategory, operatingSystem, and offers. These are appropriate for free web applications.

add_filter( 'init_plugin_suite_review_system_schema_data', function( $schema, $post_id, $type ) {
    if ( $type === 'WebApplication' ) {
        $schema['applicationCategory'] = 'WebApplication';
        $schema['operatingSystem']     = 'All';
        $schema['browserRequirements'] = 'Modern browser with JavaScript enabled';
        $schema['offers']              = [
            '@type'         => 'Offer',
            'price'         => '0',
            'priceCurrency' => 'USD',
        ];
    }

    return $schema;
}, 10, 3 );

Result

When users visit a page using the template-tools.php template, the plugin will automatically render the following schema in the page’s HTML:

{
  "@context": "https://schema.org",
  "@type": "WebApplication",
  "name": "Page Title",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": 4.9,
    "reviewCount": 182,
    "bestRating": 5
  },
  "applicationCategory": "WebApplication",
  "operatingSystem": "All",
  "browserRequirements": "Modern browser with JavaScript enabled",
  "offers": {
    "@type": "Offer",
    "price": "0",
    "priceCurrency": "USD"
  }
}

Declaring the correct schema type allows Google to better interpret your content and may enable rich snippets for web apps in search results.

Comments


  • No comments yet.

Init Toolbox

Press Ctrl + \ on desktop, or swipe left anywhere on mobile.

Login