Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.