Quantcast
Channel: How-to – Rushtips.com
Viewing all articles
Browse latest Browse all 23

How To Add Rel Author To Your Blog

$
0
0
gpluslink1.png

Nowadays when you search through google for information, you sometimes come across an authors profile picture. This is a very nice feature and it helps you get more traffic, because it feels more personal, professional and a picture next to a bunch of text stands out. So, I will let you know how you can do that on your blog. I will also include the steps to implement your Google+ link to your Joomla posts.

Rel Author

If you’re not on Joomla, you can add rel author tag before </head>.

<link rel="author" href="https://plus.google.com/u/0/108436111276035703271/posts" />

Or you can add rel author by adding a link it in your post, like this.

<a href="https://plus.google.com/109412257237874861202?  rel=author">Author Name</a>

The plus.google.com link should point to your Google+ profile.

For Joomla

If you’re on Joomla and want to add a link to your Post, like this:

gpluslink1   How To Add Rel Author To Your Blog

Step 1

  • Download this file vNetWebAuthor.txtRename it to vNetWebAuthor.php and place it in the components/com_content/helpers directory.

Step 2

Now locate components/com_content/views/category/tmpl/blog_item.php and find (ctrl+f) <dd class=”createdby”>.

If you want to add it to an article, you want to add it to components/com_content/views/article/tmpl/default.php.

The code you want to change should be on line 127 until line 142, change with exactly the same code as I have written below.

You want to replace this code:

<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
    <dd class="createdby">
    <?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
    <?php if (!empty($this->item->contactid) && $params->get('link_author') == true): ?>
    <?php
        $needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
        $menu = JFactory::getApplication()->getMenu();
        $item = $menu->getItems('link', $needle, true);
        $cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
    ?>
        <?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
    <?php else: ?>
        <?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
    <?php endif; ?>
    </dd>
<?php endif; ?>

With this code:

<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
   <dd class="createdby">
   <?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
   <?php if (!empty($this->item->contactid) && $params->get('link_author') == true): ?>
   <?php
      $needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
      $item = JSite::getMenu()->getItems('link', $needle, true);
      $cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
   ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
   <?php else: ?>
    <?php
$db = JFactory::getDbo();
$query = 'SELECT `webpage` FROM `#__contact_details` WHERE `id` = '. (int) $this->item->contactid;
$db->setQuery($query);
$page = $db->loadResult().'?rel=author';
echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($page), $author));
?>
   <?php endif; ?>
   </dd>
<?php endif; ?>

Step 3

Almost done.
Go to the Joomla Control Panel>Components>Contacts and add a new contact profile for the author you want this to apply to.
In the website field, add your google+ profile link and Save.

Note: You may have to turn off link author in the article manager > options > articles.

Big thanks to: James Weir for writing the original post and code. As well as for helping people!

flattr this!


Viewing all articles
Browse latest Browse all 23

Trending Articles