Hi, please

Let’s be clear on this – the difference between Filters and Hooks

Actually, it is much simpler than you might think:


Replaces or changes an existing function (from the original Wordpress code, from your Template theme or even one declared by you). It can completely replace the function like here:

function childtheme_postheader() {
	echo 'bacon';

Or change the function by adding to it, like here:

function childtheme_posttitle($posttitle) {
	return '<div class="containing">' . $posttitle . '</div>';

More about Filters

Action Hooks

Hooks are used to stick a new function (not change an existing one) in different places in the page. There are several hooks in Thematic, each of them can be used as an empty placeholder to be used whenever you want to stick more html or php anywhere in your site


// First we make our function
function childtheme_welcome_blurb() {
  // We'll show it only on the HOME page IF it's NOT paged
  // (so, not page 2,3,etc.)
  if (is_home() & !is_paged()) { ?>
    <!-- our welcome blurb starts here -->
    <div id="welcome-blurb">
      <p>Welcome to <?php bloginfo('name'); ?>.</p>
    <!-- our welcome blurb ends here -->
  <?php }
} // end of our new function childtheme_welcome_blurb
// Now we add our new function to our Thematic Action Hook

More about Action Hooks

2 Trackbacks

  1. [...] If you’re still unclear on this, read my post about Filters / Action hooks [...]

  2. [...] Filters and Hooks in PHP [...]

Post a Comment

You must be logged in to post a comment.