Hi Wes,
I’m trying to use twitter cards and put some code into what would be the above file. Could you advise where this file is or how I can get this code into the appropriate place.
Open your header.php file and paste the following code before the closing of the head tag.
view source
print?
01
<?php
02
#twitter cards hack
03
if
(is_single() || is_page()) {
04
$twitter_url
= get_permalink();
05
$twitter_title
= get_the_title();
06
$twitter_desc
= get_the_excerpt();
07
$twitter_thumbs
= wp_get_attachment_image_src( get_post_thumbnail_id(
$post
->ID), full );
08
$twitter_thumb
=
$twitter_thumbs
[0];
09
if
(!
$twitter_thumb
) {
10
$twitter_thumb
=
'http://www.gravatar.com/avatar/8eb9ee80d39f13cbbad56da88ef3a6ee?rating=PG&size=75'
;
11
}
12
$twitter_name
=
str_replace
(
'@'
,
''
, get_the_author_meta(
'twitter'
));
13
?>
14
<meta name=
"twitter:card"
value=
"summary"
/>
15
<meta name=
"twitter:url"
value=
"<?php echo $twitter_url; ?>"
/>
16
<meta name=
"twitter:title"
value=
"<?php echo $twitter_title; ?>"
/>
17
<meta name=
"twitter:description"
value=
"<?php echo $twitter_desc; ?>"
/>
18
<meta name=
"twitter:image"
value=
"<?php echo $twitter_thumb; ?>"
/>
19
<meta name=
"twitter:site"
value=
"<a href="
http:
//twitter.com/libdemvoice" target="_blank" rel="nofollow">@libdemvoice</a>" />
20
<?
21
if
(
$twitter_name
) {
22
?>
23
<meta name=
"twitter:creator"
value=
"@<?php echo $twitter_name; ?>"
/>
24
<?
25
}
26
}
27
?>
I am grateful for your input.