Can i add custom code in Source in specific page, Header from function.php?

there are many plugins that do some job but can i add custom code per page? Also i mean specific code by pages,posts? with function.php? For example, that code will appear every page:

function hook_link() {
    ?
        link href="http://buhehe.de/wp-content/uploads/2017/12/Buhehe.ico" rel="shortcut icon" type="image/x-icon"
    ?php
}
add_action('wp_head', 'hook_link');

Can i make something like this with function.php for every page customed and specified?

Topic php plugins Wordpress

Category Web


You can add conditions in you function if you want to add icons like this method you mentioned in question.

function hook_link() {

  global $post;
  if ($post->post_type == 'page' && $post->ID == 'whatever page id') {
    echo '<link href="http://buhehe.de/wp-content/uploads/2017/12/Buhehe.ico" rel="shortcut icon" type="image/x-icon">';
  }
  ?>

  <?php
}

add_action('wp_head', 'hook_link');

to check page or post etc you can use is_page() and is_single() functions.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.