Skip to contentSkip to main navigation Skip to footer

Add Custom JSON-LD Structured Data

🚨 This article shares details about an older version of this feature.  For information regarding the most recent version, please check out this resource: JSON-LD Structured Data.


With Squirrly SEO plugin you can customize the JSON-LD Type and Code for each URL on your website using the Squirrly SEO Snippet or by calling the sq_description hook in your code.

You can find this under Squirrly SEO > Bulk SEO > METAs > JSON-LD > JSON-LD Code > Custom Code

To edit the JSON-LD using SEO Snippet follow the instructions detailed here >

Additional JSON-LD Structured Data

To edit the JSON-LD using the sq_json_ld_data hook, activate Squirrly SEO plugin and add this code in function.php file:

//Hook the Squirrly sq_structured_data_type_for_page and add custom types
add_filter('sq_structured_data_type_for_page', 'custom_squirrly_json_ld_types');
function custom_squirrly_json_ld_types($types) {
    $types[] = 'Organization';
    return $types;
} 

//Hook the Squirrly sq_json_ld_data
add_filter('sq_json_ld_data', 'custom_squirrly_json_ld');
function custom_squirrly_json_ld($data) {
    global $post;

    $markup['@type'] = 'Organization';
    $markup['@id'] = get_permalink($post->ID);
    $markup['url'] = get_permalink($post->ID);
    $markup['contactPoint'] = array(
        '@type' => 'ContactPoint',
        'telephone' => '+1000000000000',
        'contactType' => 'Customer Service',
    );
    $markup['logo'] = array(
        '@type' => 'ImageObject',
        'url' => 'path to logo image',
    );

    $markup['sameAs'] = array(
        'facebook_site' => 'https://www.facebook.com/yuor profile'
    );

    $data[] = $markup;

    return $data;
}

First you need to call the filter sq_structured_data_type_for_page to register a new json-ld type in Squirrly SEO JSON-LD

After you registered the json-ld type, you can call sq_json_ld_data to add new data into json-ld array. Make sure you customize the data with your company information.

You can also add new Schema.org types like reviews, product, blogarticle, article , profile, etc.

Brute JSON-LD Script

If you want to build your own JSON-LD code, you can use this schema markup generator >

In Squirrly SEO, you can hook the sq_json_ld and add a brute JSON-LD code like this:

//Hook the Squirrly sq_json_ld
add_filter('sq_json_ld', 'custom_squirrly_json_ld', 100);
function custom_squirrly_json_ld() {

    return '<script type="application/ld+json">
            {
              "@context": "https://schema.org/", 
              "@type": "BreadcrumbList", 
              "itemListElement": [{
                "@type": "ListItem", 
                "position": 1, 
                "name": "",
                "item": ""  
              },{
                "@type": "ListItem", 
                "position": 2, 
                "name": "",
                "item": ""  
              }]
            }
            </script>';
}

Was This Article Helpful?