• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Appfinite

Appfinite

Premium WordPress Themes for The Genesis Framework

  • Themes
  • Blog
  • Tutorials and Resources
  • Forums
  • Contact Us

header.php

Home › Community Forums › Optimal Theme Support › header.php

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 3 months ago by Wes.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 30, 2012 at 8:25 pm #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.

    December 30, 2012 at 10:37 pm #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.

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

Primary Sidebar

Search Forums

Affiliate Program

Looking to earn some money? Join our Affiliate program and earn 35% of every sale you refer. Top referrers earn 40-50%.

Join Now →

The Genesis Framework

All of our themes are designed for the Genesis Framework. You will need to purchase Genesis in order to use any of our themes.

Purchase Genesis

Hire a Web Developer

Need help setting up or customizing your website?

Contact Us →

Search Full Site

  • Buy Genesis!
  • Shopping Cart
  • Themes
  • My Account
  • Support Forums
  • Tutorials and Resources
  • Privacy Policy
  • Contact Us
  • Follow Us on Twitter

Copyright © 2023 · Appfinite · Built With The Genesis Framework