PHPackages                             mindkomm/theme-lib-structured-data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mindkomm/theme-lib-structured-data

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mindkomm/theme-lib-structured-data
==================================

Structured Data helper classes for WordPress themes

2.0.0(7y ago)0315MITPHPPHP &gt;=7.0.0

Since Feb 13Pushed 7y ago3 watchersCompare

[ Source](https://github.com/mindkomm/theme-lib-structured-data)[ Packagist](https://packagist.org/packages/mindkomm/theme-lib-structured-data)[ RSS](/packages/mindkomm-theme-lib-structured-data/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Structured Data
===============

[](#structured-data)

Structured Data helper classes for WordPress themes.

Supports the following data types:

- [Local Business](https://developers.google.com/search/docs/data-types/local-businesses)
- [Website](https://developers.google.com/search/docs/data-types/sitelinks-searchbox)

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require mindkomm/theme-lib-structured-data
```

Usage
-----

[](#usage)

Put the generated output into the `` of your HTML.

```
add_action( 'wp_head', function() {
    // Local Business
    $local_business = new Theme\Structured_Data\Local_Business( $options );
    echo $local_business->generate_jsonld();

    // Website
    $website = new Theme\Structured_Data\Website();
    echo $website->generate_jsonld();

    // Logo
    $logo = new Theme\Structured_Data\Logo( $logo_url );
    echo $logo->generate_jsonld();

    // Social profiles
    $social_profiles = new Theme\Structured_Data\Social_Profile( $social_profiles );
    echo $social_profiles->generate_jsonld();
} );
```

### Website

[](#website)

The class checks if it can find a `search.php` file in your theme directory and will include a [potential search action property](https://developers.google.com/search/docs/data-types/sitelinks-searchbox#modified-type-website) accordingly. If you want to have more control over this, you can pass a boolean to the `generate_jsonld()` function:

```
// Use SearchAction, ignore check for search.php file.
echo $website->generate_jsonld( true );
```

### Local Business

[](#local-business)

A Local Business entry can take a lot of data. The following types of data are supported:

- **Contact Data** – Address, phone number, email address, etc.
- **Geocodes** – The latitude and longitude of where the business is located on the map.
- **Opening hours** – The opening hours of a business.

You need to pass this data when you instantiate the class in the form of an array. Here’s an overview over all the options you can pass in:

```
