The most basic application of add_action()
is to add custom code to be executed at a certain location in a WordPress installation's source-code - either using actions supplied by the Core of WordPress, or ones created by third-party code such as plugins and themes.
To add content to the <head></head>
section of the site - say to a add <link>
meta element to indicate where copyright information for the site can be found - add_action()
can be used to attach a function that prints the appropriate markup to the 'wp_head'
action (which "triggers" when WordPress builds the <head>
section):
function add_copyright_meta_link() {
echo( '<link rel="copyright" href="' . get_home_url() . '/copyright">' );
}
add_action( 'wp_head', 'add_copyright_meta_link' );