The custom action hooks can be used to output content in specific parts of the theme on any specified context (see the Hook contexts page). The syntax of the hook name is:
tcr_{context}_{tag}
You can use any of the tags in the table below for the {tag} part of the hook name, you can find the {context} you want on the Hook contexts page. For more guidance, see the example below the table. You may want to look in header.php and footer.php to see exactly where the hooks are within the source.
Tag | Description |
---|---|
head | In the <head> section |
body_start | Immediately after the opening <body> tag |
header | Before the page header |
after_header | After the page header |
before_content_style | Before the content style wrapper |
before_content | Before the page content |
after_content_style | After the content style wrapper |
after_content | After the page content |
sidebar_start | Before the sidebar |
sidebar_end | After the sidebar |
before_footer | Before the footer |
footer | Inside the footer |
after_footer | After the footer |
body_end | Immediately before the closing </body> tag |
Example
Add a subscribe form content after all single posts
1 2 3 4 5 6 7 8 9 10 | add_action('tcr_singular-post_after_content', 'tcr_add_subscribe_form'); function tcr_add_subscribe_form() { if (function_exists('iphorm')) { $output = '<h2>Thanks for reading, why not subscribe for updates?</h2>'; $output .= iphorm(2); return $output; } } |
add_action('tcr_singular-post_after_content', 'tcr_add_subscribe_form'); function tcr_add_subscribe_form() { if (function_exists('iphorm')) { $output = '<h2>Thanks for reading, why not subscribe for updates?</h2>'; $output .= iphorm(2); return $output; } }