0

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?

0

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.

5

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.