SoftwareApplication Structured Data for an App Page
Adds SoftwareApplication JSON-LD (operating system, category, price and optional rating) to the page that presents your app, plugin or SaaS product.
Opens WPIDE on
Code
// App details and the ID of the page that presents it.
$wpide_app = array(
'page_id' => 42,
'name' => 'Acme Planner',
'os' => 'Web, iOS, Android',
'category' => 'BusinessApplication',
'price' => '0',
'currency' => 'USD',
'rating_value' => '',
'rating_count' => '',
);
add_action( 'wp_head', function () use ( $wpide_app ) {
if ( ! is_page( (int) $wpide_app['page_id'] ) && ! is_single( (int) $wpide_app['page_id'] ) ) {
return;
}
$data = array(
'@context' => 'https://schema.org',
'@type' => 'SoftwareApplication',
'name' => $wpide_app['name'],
'operatingSystem' => $wpide_app['os'],
'applicationCategory' => $wpide_app['category'],
'url' => get_permalink( (int) $wpide_app['page_id'] ),
'offers' => array( '@type' => 'Offer', 'price' => $wpide_app['price'], 'priceCurrency' => $wpide_app['currency'] ),
);
if ( is_numeric( $wpide_app['rating_value'] ) && absint( $wpide_app['rating_count'] ) ) {
$data['aggregateRating'] = array( '@type' => 'AggregateRating', 'ratingValue' => $wpide_app['rating_value'], 'ratingCount' => absint( $wpide_app['rating_count'] ) );
}
echo '<script type="application/ld+json">' . wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG ) . "</script>\n";
} );
Notes
Only add a rating when it comes from real, visible reviews; leave rating_value empty otherwise.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.