Top
Manually Add Code to WordPress Header and Footer - Catatan Si Boy
fade
466
post-template-default,single,single-post,postid-466,single-format-standard,eltd-core-1.1.1,flow child-child-ver-1.0.0,flow-ver-1.3.7,,eltd-smooth-page-transitions,ajax,eltd-grid-1300,eltd-blog-installed,page-template-blog-standard,eltd-header-vertical,eltd-sticky-header-on-scroll-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-dropdown-default

Manually Add Code to WordPress Header and Footer

Manually Add Code to WordPress Header and Footer

If you’re familiar with the basics of PHP, we recommend you stick with this method. The manual method might be suitable for you.

While you can add code snippets directly to your header.php and footer.php files, a better way is to use your functions.php file and the appropriate WordPress hook. This lets you keep all your snippets in one place and avoid modifying core theme files.

– Add Code Snippets to functions.php File

– To add code to your header, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
?>
PASTE HEADER CODE HERE
<?php
};

– To add code to your footer, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_footer', 'your_function_name');
function your_function_name(){
?>
PASTE FOOTER CODE HERE
<?php
};

 

Note:

  • The comment description (helpful when you need to remember what a code snippet does a year later)
  • The your_function_name placeholder (both instances)
  • The PASTE HEADER/FOOTER CODE HERE placeholder
GD Star Rating
loading...
Manually Add Code to WordPress Header and Footer, 5.0 out of 5 based on 1 rating
No Comments

Post a Comment