Meta Data in Blogs
Hi, I'm working on the SEO for a blog and need some help. On each post I have added tags until the meta and social section but when I view the page source they do not appear? Code below for post.php
<?php perch_blog_post(perch_get('s'));
# 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
perch_page_attributes_extend(array(
'description' => $description,
'og_description' => $description,
'og_title' => $title,
'og_type' => 'article',
'sharing_image' => $fbimage,
'og_author' => 'https://www.facebook.com/JohnMarkFilms',
));?>
global.header.php code:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php perch_layout_var('title'); ?></title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Font -->
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/elegant-font.css">
<link rel="stylesheet" href="css/linearicons.css">
<!-- REVOLUTION STYLE SHEETS -->
<link rel="stylesheet" type="text/css" href="revolution/css/settings.css">
<!-- REVOLUTION LAYERS STYLES -->
<link rel="stylesheet" type="text/css" href="revolution/css/layers.css">
<!-- REVOLUTION NAVIGATION STYLES -->
<link rel="stylesheet" type="text/css" href="revolution/css/navigation.css">
<!-- OWL CAROUSEL
================================================== -->
<link rel="stylesheet" href="css/owl.carousel.css">
<!-- SCROLL BAR MOBILE MENU
================================================== -->
<?php
perch_page_attribute('description', array(
'template' => 'seo.html'
));
?>
<link rel="stylesheet" href="css/jquery.mCustomScrollbar.css" />
<?php
$domain = 'https://'.$_SERVER["HTTP_HOST"];
$url = $domain.$_SERVER["REQUEST_URI"];
$sitename = "John Mark Films";
$twittername = "@johnmarkfilms";
$sharing_image = '/images/collection.jpg';
PerchSystem::set_var('domain',$domain);
PerchSystem::set_var('url',$url);
PerchSystem::set_var('sharing_image',$sharing_image);
PerchSystem::set_var('twittername',$twittername);
perch_page_attributes(array(
'template' => 'default.html'
));
?>
<!-- Main Style -->
<link rel="stylesheet" href="style.css">
<!-- color scheme -->
<link rel="stylesheet" href="switcher/demo.css" type="text/css">
<link rel="stylesheet" href="switcher/colors/yellow.css" type="text/css" id="colors">
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="favicon.png">
</head>
Thanks!
What order to these appear in?
The social is first with tags underneath. Neither are working.
Where does
perch_page_attributes()
get called in relation to this? After it, right?Ah right, is that what I'm missing? I've put it in straight after
perch_page_attributes_extend
and still nothingYou do need to actually output the page attributes, yes.
If you add
<perch:showall />
to the attribute template you're using at that point, do you see yourog_
values available in the template?So now I've got
Still nothing, I do want the og values as well
What does
<perch:showall />
output in thatdefault.html
template?This is default.html
seo.html
facebook.html
twitter.html
Please let me know if I'm not being clear enough, but what does it output?
Nothing. It outsputs everything on the other pages but not the blog posts.
Is it finding the template? What does debug say?
What are you doing on line 23 of
post.php
?$description = strip_tags($post['0']['excerpt']);
Where is
$post
populated? I can't see that in any of the code you've shown.I'm not sure, I just got the code for it off the docs. What do I need to set
$post
as?Where did you get it from?
I'm not really sure. I can't find it now. How do I fix it?
It looks like you're missing the start of the code - so I'm not sure what you're trying to do here.
All I want is to add meta data and og to blog posts :)