We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Problem, Configuration

Social meta for blog app

I know this is a topic that is often posted here but I've been through all the posts and tried a variety of methods and still, I can't seem to get this working.

I did note that Drew replied to one thread where he set up his own test and managed to get it working so I can only think that most of us are missing a step somewhere along the line.

The meta templates are exactly the same as per the documentation: https://solutions.grabaperch.com/integrations/facebook-and-twitter-sharing

perch version: 2.8.13

So I have the following setup.


if (!perch_layout_var('blog', true)) {
    $domain        = 'http://'.$_SERVER["HTTP_HOST"];
    $url           = $domain.$_SERVER["REQUEST_URI"];
    $sitename      = "My site name";
    $twittername   = "@mysitename";
    $sharing_image = '/images/social_tile_fallback_img.jpg';

    echo "<!-- this is not the blog -->";
} else {
    echo "<!-- this is the blog -->";

  'template' => 'default.html'    

And calling the header in my post.php

# get the post
$post = perch_blog_custom(array(
    'filter' => 'postSlug',
    'match' => 'eq',
    'value' => perch_get('s'),
    'template'   => 'blog/posts.html',
    'skip-template' => true,
    'return-html'   => true,

# set up the variables
$title       = $post['0']['postTitle'];
$description = strip_tags($post['0']['excerpt']);
if (isset($post[0]['fbimage'])) {
    $fbimage = $post[0]['fbimage'];
} else {
    $fbimage = '';
# use the variables in the array value 
    'description'    => $description,
    'og_description' => $description,
    'og_title'       => $title,
    'og_type'        => 'article',
    'sharing_image'  => $fbimage,
    'og_author'      => 'https://www.facebook.com/myfbname',

perch_layout('global.header', array(
    'title'           => perch_blog_post_field(perch_get('s'), 'postTitle', true) ,
    'blog' => true,

Now when I visit the blog, I can see the comment coming out the indicated the layout variable works, however I see no meta. I've tweaked and played and started from scratch and still nothing. I know there are methods where I could write the meta directly into the page but I am keen to get to the bottom of this issue for future projects as it feels like this is a much cleaner way if I can get it working.

Please let me know if anymore information is required.

Mathew Doidge

Mathew Doidge 2 points

  • 4 years ago

I would be really interested to see this too - as Mat says this could be a standard drop-in for pretty much every build.

The only thing I would add is that the vars could be set in an array, but sorry no idea why it isn't working!

Drew McLellan

Drew McLellan 2638 points
Perch Support

It seems like a lot of people are having trouble with this and I really can't figure out why.

Would it be possible to post the code from the Perch blog post page template anywhere Drew?

It seems to be working there. Hopefully someone can figure out from that what we’re all doing wrong.

I would really like this as well. I can't figure it out when it comes to blog posts.