From Codex Action Reference:
init
Runs after WordPress has finished loading but before any
headers are sent. Useful for
intercepting $_GET or $_POST triggers.
wp_head
Runs when the template calls the wp_head function. This hook
is generally placed near the top of a
page template between <head> and
</head>. This hook does not take any
parameters.
Basically wp_head
runs when page is already being loaded, while init
runs before that.
Also don’t forget that init
fires on admin pages as well and anything front-end related must be excluded from there with !is_admin()
check.
Related Posts:
- What is the entry point of a WordPress theme?
- WordPress ignore init for crawlers
- Init hook function to call other hook in function.php
- How to fix “Attempted relative import in non-package” even with __init__.py
- git add . -> still “nothing to commit” with new files
- How to fix “Attempted relative import in non-package” even with __init__.py
- Inheritance and init method in Python
- What is the very earliest action hook you can call?
- Which hook should be used to add an action containing a redirect?
- How to Link External jQuery/Javascript files with WordPress
- Marking future dated post as published
- Difference between after_setup_theme and init action hooks?
- Add tags to the section via functions.php
- WordPress Theme activation hook?
- Use wp init hook to call other hooks?
- Why is wp_head() creating a top margin at the top of my theme header?
- WordPress Code Flow
- How can I remove the site URL from enqueued scripts and styles?
- How to add stylesheets only to pages with specific shortcode?
- force enqueue script to be first in order of prominence
- How can i get the name parameter defined in get_header?
- What does l10n.js do in WordPress 3.1? And how do I remove it?
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- Remove meta robots tag from wp_head
- Caching and Versioning for rtl.css
- How do I force wp_enqueue_scripts to load at the END of ?
- Two title tags in my header
- Is there a way to read or list wp_head() contents?
- wp_head() gives me some weird CSS
- Are there any action like ‘init_frontend’
- How can I modify what is being output in wp_head, whether by a theme or WordPress in general?
- Removing specific style from wp_head
- Multi-page posts do not get indexed by Google due to canonical URLs
- Change Page’s Tag Using functions.php File
- Init action hook running late after PayPal’s return url?
- How to control initial wp_head() output?
- Hook into wp_head(); in a plugin
- How can I reduce the amount of files loaded/included per plugin?
- Change title in head on Archive page
- When we register a custom taxonomy or post type, does the WP database modified at all?
- How can I get wp_head() as a string instead of echoing it?
- Add code into on a per page/post basis
- Modify page title format (when using title-tag)
- Remove rel=’dns-prefetch’ href=’//maps.google.com’ from wp-head
- Display custom_background outside wp_head()
- How to remove pingback from head?
- wp_head() outputs in body
- How to load different css file for different pages
- Putting content into header.php without using wp_head
- Change page title from plugin
- Track down where script is being enqueued from
- Wp_head and wp_footer vs wp_enqueue_script javascript files?
- use add_action(‘wp_head’) in a widget for generating dynamic CSS styles
- Change meta tags programatically
- How to use wp_enqueue_style() and wp_enqueue_script() only when needed?
- How to properly insert a stylesheet in wp_head
- Using get_terms for custom taxonomy in functions.php
- append stylesheet via shortcode
- Change dns-prefetch to preconnect for external enqueued resources
- Change dns-prefetch to preconnect with correct protocol
- Remove specific CSS and JS from the head
- Using auth_redirect returns cannot modify header information
- Searching hook to set cookies before and avoid “headers already sent”
- set_query_var doesn’t seem to work on init hook
- How to load plugin before the wordpress jquery?
- Why does wp_enqueue_script ignore my ‘wp_head’ hook?
- How to remove unnecessary elements in the HTML document head
- wp_head() remove redundant scripts?
- How can I make new .css file in child theme override styles in child theme’s style.css
- Manipulating wp_head content
- Intercept request to /wp-content/uploads/random.file
- Manually add admin bar
- How can i remove JUST the title tag from wp_head() function?
- Indenting (tabbing) WP_head
- Disable wordpress from including jQuery in the head section
- wp_head() not inserting the default stylesheet style.css
- Deregister CSS style link ‘open-sans-css’
- How to add iOS & fav icons to the theme?
- Filter out some plugin action in wp head / wp_footer
- add_feed and flush_rewrite_rules
- Move all the JS files to the bottom|footer, the right way
- Add HTML to single post tag
- add_action and wp_head not display content in head section
- wp_redirect() not working on form submission with init hook
- How to add inline css/js inside a shortcode
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- wp_head() not including styles and javascripts after a template redirect
- What is the best filter where to use register_block_type?
- Header has extra HTML block at top before my code
- Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
- wp_head function causes 30px blank space [closed]
- Cron While Editing Post
- Best action hook to create custom post and assign taxonomy terms to it on plugin activation?
- add action wp_head not working
- Replace category titles
- Remove all theme CSS & JS from wp_head (but only for 1 page template)
- Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
- wp_head hook by page ID [closed]
- Remove Genericons Helper CSS from twentyfourteen theme
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?