Support » Plugin: WordPress SEO Plugin - Rank Math » JSON-LD structured data not outputting when posts made via plugins

  • Resolved Arijit Biswas

    (@dibbyo456)


    If a post is made via a 3rd party plugin, then the JSON-LD structure data not outputting.
    But if we hit update button on that post, then json-ld data shows up.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author MyThemeShop

    (@mythemeshop)

    Hello @dibbyo456

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Can you please tell us the steps to reproduce it so we can check on our end?

    Looking forward to helping you.

    @mythemeshop Github probably the best place to describe this type of bugs for the easy markup codes. Anyway I’m trying my best to describe it.

    I’m using an plugin to generate posts but you can reproduce the same issue with FakerPress plugin.

    1) Generate a post using FakePress, then open the posts and view the json-ld section, you will get something like this – https://s.put.re/BsNeB6vk.png

    2) now update the post, then check source again, you will get something like this – https://s.put.re/GKtz6i5T.png

    See the difference? The json-ld markups not coming up unless we hit the update button.

    • This reply was modified 5 months, 2 weeks ago by  Arijit Biswas.
    Plugin Author MyThemeShop

    (@mythemeshop)

    Hello @dibbyo456

    Thank you for helping us with the steps.

    We have done that intentionally.

    There are some Schema types where we can not autofill the data, for instance, the Recipe etc.

    Either, we need can complicate the process by adding more fields in the general settings of the plugin or we are auto-filling the data only on new posts or if someone updates an older post(s).

    In the future, we will be bringing a tool which can scan all the posts for the missing Schema data and notify the users.

    For now, one needs to manually enter the data on the older posts or update them to fetch the new information.

    If you have any suggestions for this, please let us know. We would be more than happy to consider them.

    Thank you.

    Plugin Author MyThemeShop

    (@mythemeshop)

    Hello @dibbyo456

    If you still want to use the data from the settings as the fallback then please add the following code in the functions.php file:

    add_filter( 'rank_math/json_ld', function( $json_ld, $json ) {
        if ( is_singular() && ! isset( $json_ld['richSnippet'] ) && $fallback_schema = \RankMath\Helper::get_settings( "titles.pt_{$json->post->post_type}_default_rich_snippet" ) ) {
    
            $json_ld['richSnippet'] = [
                '@context'         => 'https://schema.org',
                '@type'            => \RankMath\Helper::get_settings( "titles.pt_{$json->post->post_type}_default_article_type" ),
                'headline'         => $json->parts['title'],
                'description'      => $json->parts['desc'],
                'datePublished'    => $json->parts['published'],
                'dateModified'     => $json->parts['modified'],
                'publisher'        => $json->get_publisher( (array) $json->post ),
                'mainEntityOfPage' => [
                    '@type' => 'WebPage',
                    '@id'   => $json->parts['canonical'],
                ],
                'author'           => [
                    '@type' => 'Person',
                    'name'  => $json->parts['author'],
                ],
            ];
    
            $json->add_prop( 'thumbnail', $json_ld['richSnippet'] );
        }
    
        return $json_ld;
    }, 11, 2);

    Hope that helps. Thank you.

    @mythemeshop That’s very nice of you to give this code. Thank you so much. I will try and let you know.

    One more thing, I’m still waiting for the API docs. For example, I need to change meta title and descriptions on-the-fly.

    What filter do I need to use for that?

    If you can give me the list of available APIs (actions and filters) then it would be very nice.

    thank you.

    Plugin Author MyThemeShop

    (@mythemeshop)

    Hello @dibbyo456

    Please keep an eye on this page:
    https://rankmath.com/kb/wordpress/seo-suite/

    We will be posting a new KB article in the coming week with all the filters and hooks currently supported.

    Hope that helps. If you have any further question(s), please let us know. Thank you.

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