header.php

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2231
    pecographe
    Customer

      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.

      #2234
      Wes
      Moderator

        If the tutorial says to put it in your header.php file then you could just copy the header.php file in your Genesis Theme (The actual Framework itself), and paste it inside of the child theme that you are using. Then you can add in the code however the tutorial is suggesting you to do. Make sure you copy this file when making your edits and not the one inside the framework. Once you copy it to the child theme, it will be used instead of the one that is in the framework.

        Also, the code that you pasted above didn’t show up right. Sometimes that can happen with bbpress depending on the code and how it is pasted. If it happens again, just use something like – http://pastebin.com/ to post your code.  I’m waiting for an update, or a plugin that will fix this hopefully in the near future.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.