Skip Navigation

[Resolved] Installing a schema movie type and structured data

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer wants to add a JSON-LD script with schema.org/Movie structure to their single movie page. This JSON-LD should include information from the single post and custom fields created with Toolset, for better SEO and to help search engines understand the content.

Solution:

We suggested using Toolset Views to create a JSON output. This involves using the classic version of the view editor to structure the JSON output according to the schema.org/Movie structure. Steps include:

Enable the classic view editor in Toolset settings.
Create a new view in Toolset -> Views.
Replace the default wpv-loop tags with the necessary JSON structure in the view loop editor.
Ensure the "Disable the wrapping DIV around the View" option is selected for correct JSON formatting.
An example structure was provided to illustrate how to format the JSON output within the view.

Additionally, the customer can use the view's API function get_view_query_results to build and display the JSON output with PHP if more customization is needed.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 3 replies, has 2 voices.

Last updated by Mateus Getulio 5 months, 2 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2707473

Tell us what you are trying to do?
I'm trying to add a json with schema.org/Movie structure and custom field from Toolset.

Is there any documentation that you are following?
I have the structured Movie schema -> hidden link

Is there a similar example that we can see?
Some good practice with allocine -> hidden link

What is the link to your site?
hidden link
hidden link

I have knowledge in creating a plugin, some hooks but I'd like to know if there is a UI way to do it or the best place to shoot my json with the Toolset Post Types codes.

Thanks

#2707555

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

It looks like you're trying to either automatically create custom post types (CPTs) and fields based on the schema or import data from an external service in JSON format.

I'm afraid that Toolset isn't designed to access external data sources directly or automatically create fields and CPTs from a schema. It is meant to work with data saved in your WordPress database locally as posts, custom fields, taxonomies, and so forth. Here's what you could do:

1- Create Custom Post Types (CPTs) and group fields manually using the UI:

- Use Toolset Types to create a custom post type for Movies.
- Add the necessary custom fields to match the schema.org properties (e.g., director, actor, genre).

2- Importing Data:

- Each movie must be imported into WordPress as a custom post. This will require custom code to read the external JSON data and create posts in WordPress.
- Save each schema property as a custom field value on the Movie post.

3- Displaying Data:

When you create custom posts, WordPress automatically generates a URL where a single post can be displayed. Toolset Content Templates give you the ability to design the page shown at that URL. You can use Types and Views shortcodes to insert information about the movie, including custom field values.

Please confirm if this aligns with what you are trying to achieve. If you are looking for an automated solution to import JSON data and create CPTs and fields dynamically, this would likely require custom code, which is outside the scope of our support.

If implementation becomes a roadblock, you might want to explore the list of Toolset Contractors for assistance: https://toolset.com/contractors/

Feel free to provide more details if I misunderstood your requirements, and I'll reassess.

Best regards,
Mateus

#2707615

Hello Mateus,

Thank you for all that input.

My goal is to add a json in my single movie page with the movie described, for a robot to understand.
All the informations are coming from the single post (title, featured image…) and meta-data from Toolset cpt (duration, director, cast…).

Like in the allocine example above.

<script type="application/ld+json">
{
"@context":"hidden link",
"@type":"Movie",
"name":"Cosmodrama",
"image": {
"@type": "ImageObject",
"url": "hidden link"
}
,
"duration": "PT01H52M00S"
,
"genre": "Science Fiction"
,
"description": "Sept astronautes, accompagnés d’un singe, d’un chien et d’un myxomycète, sortent de cryogénisation à bord d’un vaisseau spatial. Ils ne savent pas pourquoi ils sont là, ni d’où ils viennent, ni où ils vont."
,
"director": {
"@type": "Person",
"url": "hidden link",
"name": "Philippe Fernandez"
}
,
"actor": [ {
"@type": "Person",
"url": "hidden link",
"name": "Jackie Berroyer"
}
,
{
"@type": "Person",
"url": "hidden link",
"name": "Bernard Blancan"
}
,
{
"@type": "Person",
"url": "hidden link",
"name": "Emilia Derou-Bernal"
}
,
{
"@type": "Person",
"name": "Ortes Holz"
}
] ,
"creator": {
"@type": "Person",
"name": "Philippe Fernandez"
}
,
"musicBy": {
"@type": "Person",
"name": "Sylvain Quément"
}

,
"trailer": {
"@type": "VideoObject",
"name": "Cosmodrama Bande-annonce VF",
"description": "Cosmodrama Bande-annonce VF",
"thumbnailUrl": "hidden link",
"thumbnail": {
"@type": "ImageObject",
"contentUrl": "hidden link"
},
"uploadDate": "2015-04-21",
"duration": "PT00H01M40S",
"embedUrl": "hidden link",
"url": "hidden link"
}
,
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "2,6",
"ratingCount": "37",
"reviewCount": "9",
"bestRating": "5",
"worstRating": "0,5"
}
}
</script>

Thanks again

#2707752

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Cedric,

Thank you for following up on this request.

The views plugin can give your data as a JSON output, to create a view with a JSON output you will need to use the classic version of the view editor. To enable this go to Toolset->Settings and scroll to editing experience. Select the 3rd option and then refresh the page and you should now see a new menu item at Toolset -> Views.

Navigate to Toolset -> Views and create a new view.

In the view loop editor, replace the existing wpv-loop tags with the structure needed for your JSON.

Here's a base example of how you need to structure your output:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
[
<wpv-loop>
  [wpv-item index=1]
{"id": "[wpv-post-id]",
 "title": "[wpv-post-title]",
 "duration": "[types field='duration' output='raw'][/types]",
 }
  [wpv-item index=other]
, {"id": "[wpv-post-id]",
 "title": "[wpv-post-title]",
 "duration": "[types field='duration' output='raw'][/types]",
 }
  </wpv-loop>
]
    <!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]

Obs.: Ensure that the "Disable the wrapping DIV around the View" option is selected. This will make sure that the output is in the correct JSON format without additional HTML tags.

Alternatively, you can also use view's API function: get_view_query_results and build and display the JSON output with PHP.
=> https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results

Thank you,
Mateus