I’m making a wordpress plugin that uses shortcodes to display car information. But now I need to add the facebook meta tags to the head of a page. This meta is generated in the shortcode because it contains info of a car.
I know the head can’t just be edited with wordpress because the shortcodes execute after the head is created (I think). But is there a way around to change the content in the head within a shortcode?
Here is an example of the meta data:
<!-- FACEBOOK METAS -->
<meta property="og:url" content="<<-- voertuig_url_cms -->>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<<-- merk -->> <<-- model -->> <<-- uitvoering -->> - <<-- bedrijf -->> - <<-- plaats -->>" />
<meta property="og:image" content="<<-- voertuig_foto1 -->>" />
<meta property="og:site_name" content="<<-- bedrijf -->>" />
<meta property="og:locale" content="nl_NL" />
<!-- FACEBOOK METAS -->
In the shortcode it will replace all the <<– –>> for the right information. After thats done, it should be placed in the head of the page.
Until now I only know one way to do this. That is by just generating the whole page. Get the page, add the meta and display the page again. But I think that it will make the pages very slow.
I know it should be possible, because there already exists plugins which do this, but I cannot find how.
Thanks in advance