WithCandour / statamic-aardvark-seo

Candour's SEO addon for Statamic
https://statamic.com/marketplace/addons/aardvark-seo
11 stars 18 forks source link

Programatically set the Social data #71

Closed jameswtc closed 3 years ago

jameswtc commented 3 years ago

Hi all,

Not sure if this is the right place to ask but this is the only channel I could get help regarding this Add-Ons.

I'd like to set the social data programatically using the PHP API. We have a scheduler which imports products from external sources and each of them have picture which should be shown when sharing on social media platform. How do I set the og:title, og:description, and og:image using the PHP API? Also the same for Twitter, etc.

Thanks!

James

AndrewHaine commented 3 years ago

Hi @jameswtc,

The SEO data is stored in the entry the same way as other fields so you can set this data programatically by setting the:

fields when creating the entry.

It's worth noting that the og title/description will get inherited from the meta_title and meta_description fields (and the same for the twitter fields).

Hope this helps, Andrew