Support » Plugin: The SEO Framework » Is there a filter the Organization Schema

  • Resolved mesmer7

    (@mesmer7)


    I’d like to add two lines to the organization schema, ‘knows about’ and ‘foundingdate’.

    
    "@type": "Organization",
     "name": "Hypnotic Dreams",
     "url": "http://www.hypnoticdreams.com",
     "logo": "https://www.hypnoticdreams.com/wp-content/uploads/cropped-logo.png",
     "foundingDate": "2000",
     "knowsabout": "topic 1, topic 2, topic 3, topic 4"
    

    Is there a filter I can use for this?
    … and where is the instructions for using this filter?

    • This topic was modified 3 months, 1 week ago by mesmer7.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Yes, there is a filter. Since there are so many (200+) filters available (and I can’t document them all manually), the instructions are in the plugin’s code… or, rather, per your request, here:

    add_filter( 'the_seo_framework_receive_json_data', function( $data, $key ) {
    
    	if ( 'website' === $key ) {
    		$data['foundingDate'] = '2000';
    		$data['knowsAbout']   = 'topic 1, topic 2, topic 3, topic 4';
    	}
    
    	return $data;
    }, 10, 2 );

    I think you’ll know well how to deal with that snippet 🙂 But, if you require further guidance, don’t hesitate to follow up.

    Do make sure to clear your cache after implementing it. Cheers!

    mesmer7

    (@mesmer7)

    Hi Sybre,

    Thanks for replying. I want to filter the “Organization” data. When I used your code exactly as you provided it, the data showed up under ‘website’, and Google’s testing tool said that is not invalid.

    Naturally, I tried changing ( ‘website’ === $key ) to ( ‘organization’ === $key ), but that failed to insert the data.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    Whoops, my bad.

    You should use 'links', instead of 'website'. That should do the trick 🙂

    The “links” part is inferred from a now deprecated instance. We may want to look into renaming that in a future major release.

    Cheers!

    mesmer7

    (@mesmer7)

    I NEVER would have guess ‘links’. But it works. Thanks.

    If you do rename that key, please let me know. Or at least make sure you mention it in the release notes.

    Plugin Author Sybre Waaijer

    (@cybr)

    I will mention every change, yes 🙂

    I prefer to have backward compatibility in place–but only when that’s possible.

    For TSF (and many other plugins), only major releases (where X changes: X.X.y) will have API changes for which you want to look out when you have filters or supporting plugins in place. Minor releases (y.y.X) should be safe to upgrade to whenever.

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