[Resolved] Schema Markup with Elements

Home Forums Support Schema Markup with Elements

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #1340699


    I would like to add Schema markups to my articles using a hook. I am not using any SEO or page building plugins, if possible I would like to keep it that way..

    <script type=”application/ld+json”>

    I understand that this is the script I have to insert in the header.

    Could anyone please help on how to best implement this on my posts AND how to automatically fill out the blanks. I would like to use the post’s excerpt for “description”. If I am not mistaken, WordPress automatically creates an excerpt if the manual excerpt box is empty.

    As far as keywords are concerned, is there a way to add them without using a plugin like ACF?

    Also is there a practical way to change “@type” depending on tags? Like the default being “Article” and if the article has a tag called “News”, the value will be “NewsArticle” instead.

    Thanks in advance

    Lead Developer
    Lead Developer

    Hi there,

    You could use a Hook Element for this, but it will require a certain amount of PHP/WordPress knowledge.

    To get the excerpt, you can use this function: https://developer.wordpress.org/reference/functions/get_the_excerpt/

    When it comes to getting the logo URL, width and height, this should help: https://wordpress.stackexchange.com/a/356961/90661

    The same applies for the featured image, but you’d replace $logo with get_the_ID() to get the featured image.

    Keywords could be tough depending on where they’re coming from.

    As for the type, you could try something like:

    $type = 'Article';
    if ( has_tag( 'News' ) ) {
        $type = 'NewsArticle';


    So it is not possible to add template tags like “headline”:”{{post_title}}“, to fill out the fields?

    Customer Support

    Hi there,

    Template Tags only work if they are output within a Header Element, they’re not a global thing.



    Is this approach a good idea or should I look for a way using the Loop? Not that I yet know what to do in both cases but using hooks seems more appealing.

    Any guidance would be much appreciated, I have nothing against detailed guides 😉

    Customer Support

    This is where SEO and other plugins make stuff easier. If you’re not after a full blown SEO plugin then maybe this:


    If you want to pursue the manual route then maybe this users example will help:



    I’ll try to wrap my head around the code and get back to you if there are any theme related questions.

    Thanks for the help.

    Customer Support

    That code looks like it should work as it is, its not theme specific.
    You’re welcome

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.