Pass template values inside head tag

I want to add schema values in JSON-LD inside tag. Cant find in documentation as search bar is no more available.

Hey there,
It seems like they temporarily removed it (the search bar) because there is a bug but they will put it back asap.
However, for your schema problem, I can show you how I added mine using microdata (I’m more familiar with this one)

<li itemprop="itemListElement" itemscope
      itemtype="" style="list-style: none;" class="tt-breadcrumb-item text-xs">
    <span itemscope itemtype=""
       itemprop="item" itemid="{Taxonomy=category}">
      <span itemprop="name"><Loop field=archive_term><Field title /></Loop></span></span>
    <meta itemprop="position" content="2" />

And you can simply add this in any template and put it wherever you want it to be displayed. The schema will be grabbed by SEO.

1 Like

Thanks for response and I am already using similar schema in my other website but this time I need to add it in head.

Hi Zakir,

The feature closest to what you’re describing is the Meta tag, which puts things in the document <head>.

But it’s limited to only known/defined meta fields, it doesn’t support schema yet. And it needs to run early in the page lifecycle, before wp_head action which generates everything in <head>.

The Layout template type could possibly work - but they’re currently designed to take over the whole page, so it will need an additional option (maybe location type “Head”) for this purpose.

It sounds like a useful feature, I’ve made a note of it and will come back to this comment thread to let you know when there’s progress.

1 Like

This topic of “JSON linked data” turned out to be a rabbit hole, more complex that I expected, but it’s now supported in the newest version of L&L.

The Layout template type has a new “theme position” called Document Head, which can be used to insert HTML inside the document <head>. This can be useful for adding <meta> tags, conditionally loading stylesheets, or for defining JSON-LD schema.

(There is also a new theme position called Document Foot to insert HTML at the bottom of document, for loading scripts.)

From the article Introduction to structured data markup in Google Search, I learned the recommended method is to insert the schema as a JSON string inside a script tag, like so:

<script type="application/ld+json">..</script>

The difficulty here is that, in L&L templates, a script tag is treated as a “raw” tag whose content must not be altered - so any dynamic tags inside will not be rendered. In addition, building a valid JSON string manually and dynamically is tricky.

As a solution, a new tag called JSON-LD has been added.

It works the same as the Map tag, by creating a map (also called “associative array” in PHP, or “object” in JavaScript). It then inserts a properly formatted JSON-LD script tag with the object converted to JSON string. It also automatically adds the required schema property, @context.

Here’s an example demonstrating a fairly complex JSON-LD definition, which includes a List and a child Map.

  <Key id value="" />
  <Key type value="Person" />
  <Key name value="John Doe" />
  <List images>
  <Map spouse>
    <Key id value="" />
    <Key type value="Person" />
    <Key name value="Jane Doe" />      

It creates the following schema:

  "@context": "",
  "id": "",
  "type": "Person",
  "name": "John Doe",
  "images": [
  "spouse": {
    "id": "",
    "type": "Person",
    "name": "Jane Doe"

The JSON-LD tag can be placed in a Layout template with theme position “Document Head”. Since the schema is built up using L&L tags instead of JSON, it should be much easier to integrate with dynamic data such as post fields, taxonomy, etc.

This is quite an advanced templating feature, and it still needs to be documented. Please feel free to ask for clarification.