0

I am having a bit of a problem with my Facebook sharing, and I was hoping for some input.

I'm using og meta to share my website on facebook and it work perfectly with static text. BUT when I trying with a dynamicale text using some variable it doen't work anymore for an unknown reason.

It's like if facebook get metadata's content before variable display...

This work:

<meta property="og:title" content="my title" />

This too:

<?php $title = 'my tilte'; ?>
<meta property="og:title" content="<?= $title; ?>" />

But not this:

view.ctp

$this->assign('metaTitle', $post->title);

default.ctp (cakephp layout)

<meta property="og:title" content="<?= $this->fetch('metaTitle'); ?>" />

I'm using Cakephp 3, $this->fetch is just a way to display variable from view in the layout.

In all three cases, the result is exactly the same in chrome inspector. And I already try to debug it with facebook tools

Any ideas?

Cheers!

Bechilled
  • 71
  • 7

0 Answers0