Question

I am customizing a a word press theme for my blog. I am trying to change the favicon, But I do not know how to do that. I checked all settings, there is no option for favicon. Can anybody will tell me how to change that.

Was it helpful?

Solution

I usually add a favicon in my site's root directory because some browsers look there by default.

function so18074365_favicon() {
  printf( "<link rel=\"shortcut icon\" type=\"image/vnd.microsoft.icon\" href=\"%s/favicon.ico\" />\n", site_url() );
}

add_action( 'wp_head', 's018074365_favicon' );

Add this function to your functions.php and upload your favicon.ico to your wordpress root folder.

If you want to add the favicon in yout theme folder, add this one:

function so18074365_favicon() {
  printf( "<link rel=\"shortcut icon\" type=\"image/vnd.microsoft.icon\" href=\"%s/favicon.ico\" />\n", get_stylesheet_directory_uri() );
}

add_action( 'wp_head', 's018074365_favicon' );

OTHER TIPS

Сonsidering the Wordpress Codex you'd

  1. Go to your WordPress Administration Panel.
  2. Click on Design (called Presentation in WordPress 2.3.x and below, and Appearance in WordPress 2.7+).
  3. Click on Theme Editor.
  4. Select the file called Header or header.php to edit the file.
  5. Search for the line of code that begins with <link rel="shortcut icon" and ends with /favicon.ico" />. Overwrite it, if it exists, or add the following code below the <head> HTML tag. <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />

  6. Save the changes.

Note. Dont forget to upload favico into you current theme root via any acceptable way.

Hope it helps. Cheers!

Refer wordpress codex Create a favicon

Search for the line of code that begins with <link rel="shortcut icon" and ends with /favicon.ico" />. Overwrite it, if it exists, or add the following code below the HTML tag in between <head></head>

<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />

Make sure you have the favicon.ico in your stylesheet directory

Follow this steps:

Are you trying to figure out how to change your Favicon?The favicon is a pretty small detail. I don’t think it will ever hurt your business because you don’t have a custom favicon. But when you do have one, it’s one of those little details that people notice, and can impress them, even if it’s subconscious.

The helpful tool I want to show you is at Favicon (dot) cc.

You’ll notice you have a full editor with 16 by 16 pixel dimensions. When I used to use photoshop for this task, it was a bit challenging trying to get an image to look right with such small dimensions. This tool makes it easier, because you can edit it large like this… and preview it small below. Their image import feature makes it even easier. This way their software does all the hard work, and you can quickly decide if you like it or not.

Don’t worry that the enlarged picture looks distorted. It will actually look as a small favicon. To download it, click on “Download Favicon.” Pretty simple.

Just follow the same steps…

First I’ll upload the image…

Then check to see how it looks…

And if I like it, I can download it.

Give it a few hours and your favicon will update throughout the internet. When I first did this, I expected it to update instantly, and when it didn’t, I thought I missed a step. That’s really all you have to do, just give it time, and your new favicon will appear.

If you follow the steps in the course, you will start pulling in magnetic traffic to your website, and build a huge online following.

http://www.gowallaby.com/how-to-change-favicon-in-wordpress

If you want change the Favicon using the option "Customise" at "Appearance/Customise" you can do:

At function.php add the code:

function themeslug_theme_customizer_favicon( $wp_customize ) {
    // Fun code will go here

    $wp_customize->add_section( 'themeslug_favicon_section' , array(
      'title'       => __( 'Favicon', 'themeslug' ),
      'priority'    => 30,
      'description' => 'Upload a favicon to your Wordpress',
  ) );
    $wp_customize->add_setting( 'themeslug_favicon' );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_favicon', array(
      'label'    => __( 'Favicon', 'themeslug' ),
      'section'  => 'themeslug_favicon_section',
      'settings' => 'themeslug_favicon',
  ) ) );
}
add_action('customize_register', 'themeslug_theme_customizer_favicon');

and at the header.php between the tags <header></header> add the code:

  <?php if ( get_theme_mod( 'themeslug_logo' ) ) : ?>
      <link rel="shortcut icon" href="<?php echo esc_url( get_theme_mod( 'themeslug_favicon' ) ); ?>" />
  <?php endif; ?>

Now go to Appearance/Customise and will have a section "Favicon", just upload your file.png and enjoy

function add_my_favicon() {
    $favicon_path = plugins_url( '/favicon.ico', __FILE__ );    
    echo '<link rel="shortcut icon" href="' . $favicon_path . '" />';
}

add_action( 'wp_head', 'add_my_favicon' ); //front end
add_action( 'admin_head', 'add_my_favicon' ); //admin end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top