Title: How to inject /insert code into header using a function
Last modified: August 20, 2016

---

# How to inject /insert code into header using a function

 *  [jester48](https://wordpress.org/support/users/jester48/)
 * (@jester48)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-inject-insert-code-into-header-using-a-function/)
 * I would like to insert a code block from my plugin, the code block needs to be
   added to the page header but can’t find an appropriate way to call it.
    i need
   to target `<header id="branding" role="banner"">` and have my html inserted right
   after this or at least inside `<div id="page" class="hfeed">`
 * is there a way to do this or will i need to create a custom header?
 * TIA

Viewing 1 replies (of 1 total)

 *  [camelman](https://wordpress.org/support/users/camelman/)
 * (@camelman)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-inject-insert-code-into-header-using-a-function/#post-2592424)
 * i use this function:
 *     ```
       <?php
       function addfavicon() {
       	if (is_single() || is_page()) { /* If Post or Page */
       		 echo '<link rel="shortcut icon" href="' .bloginfo('stylesheet_directory'). 'images/favicon.ico">';
       	}
       }
       add_action('wp_head', 'addfavicon', 1);
       ?>
       ```
   
 * dose this helps?

Viewing 1 replies (of 1 total)

The topic ‘How to inject /insert code into header using a function’ is closed to
new replies.

## Tags

 * [header](https://wordpress.org/support/topic-tag/header/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [camelman](https://wordpress.org/support/users/camelman/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-inject-insert-code-into-header-using-a-function/#post-2592424)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
