3

I want to add iOs, Android and favourite icons to the website. Generally I udnerstand how they shold be implomented: link files in the head section and you good to go, however there are many lines (for both devices and favico makes more than 10), so I do not know how to add them correctly:

  1. Somehow enqueue them in the functions.php?
  2. Some people on the internet mention creating a Site-Specific Snippets Plugin?
  3. Use some sort of plugin for that (not big fan of this idea)?
  4. Just add the links to header.php (that is what codex suggests).

Just in case, the code:

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png" />
4

Hook into wp_head in your functions.php file.

add_action('wp_head', 'add_your_stuff');
function add_your_stuff() {
    ?>
    <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri();?>/favicon.ico" type="image/x-icon" />
    <link rel="apple-touch-icon" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon.png" />
    <link rel="apple-touch-icon" sizes="57x57" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-57x57.png" />
    <link rel="apple-touch-icon" sizes="72x72" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-72x72.png" />
    <link rel="apple-touch-icon" sizes="76x76" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-76x76.png" />
    <link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-114x114.png" />
    <link rel="apple-touch-icon" sizes="120x120" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-120x120.png" />
    <link rel="apple-touch-icon" sizes="144x144" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-144x144.png" />
    <link rel="apple-touch-icon" sizes="152x152" href="<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-152x152.png" />
    <?php
}
  • Crap, sorry, didn't see they were images. Time for bed :-). Sorry about that – Pieter Goosen Aug 14 '14 at 18:59
  • No worries - you had me second guessing myself for a minute :) – Welcher Aug 14 '14 at 19:02
0

I would not recommend hard-coding them into either the header.php template file or functions.php. The reason is that they are then tied into your theme, and if you switch themes you will lose them.

Option 3 I tend to stay away from, because the third-party plugins tend to bring along a lot of extra bloat.

My advice would be to go with option 2, as it is lightweight, and is not tied into the theme. If you switch themes, your custom link tags will still be intact.

  • i will try this option, but for now I will hook it up to head through functions.php – nerijusgood Aug 14 '14 at 19:05

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.