0

I'm trying to add a Google Plus html tag via direct linking (see here) to my head but can't get it to work. What I'm trying is this inside my template.php file:

$googleplus = array(
    '#tag' => 'a',
    '#attributes' => array(
        'rel' => 'publisher',
        'href' => 'https://plus.google.com/+MyPage'
    )
);
drupal_add_html_head($googleplus, 'googleplus');

Nothing shows up for me. Is there a better/working way of doing this?

  • Where are you adding that? In template.php, hook_preprocess_html should work there. – David Thomas Nov 21 '13 at 22:22
  • @DavidThomas Doing it in preprocess_html puts it in the body tag, not the head – adamzwakk Nov 22 '13 at 15:59
  • that's incorrect. hook_preprocess_html is for html.tpl.php which is the html wrapper including the head section of the document. – David Thomas Nov 23 '13 at 0:23
3

Create block and place in Header Top. Go to Structure -> Block -> Add Block, then in Block body, write custom HTML. Below block body, Text format should be in "FULL HTML" to display the image.

<a href="https://www.google.com/.." target="_blank"><img src="YOURIMAGE" width="64" height="64"></a>

I think it will work.

1

Just came across this from a google search, and what I think you want to do is add a LINK or an A tag to the head section of your html page to tie together your Google+ page and your website..

This worked for me in template.php - remember to clear cache:

function YOURTHEMENAME_preprocess_html(&$vars) {
  $googleplus = array(
   '#tag' => 'link', 
   '#attributes' => array(
     'href' => 'https://plus.google.com/GOOGLEPLUSACCOUNT', 
     'rel' => 'publisher',
    ),
  );
 drupal_add_html_head($googleplus, 'googleplus');
}
0

Just like J singha said, create a block (full html) and as body you paste a the link google gave you. After you have submitting, you will see a Google+ link appear on the place where you have placed your block.

  • This answer is a duplicate answer from J Singha. If you want to support an answer is better to upvote tu right answer instead of add the same answer. – sanzante Mar 19 '14 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.