ThemeShaper Forums » Thematic


add_filter calling origin function

(6 posts)
  • Started 9 years ago by turbobutton
  • Latest reply from helgatheviking
  • This topic is resolved
  1. superb system design. great use of hooks and filters.

    so im looking to add (prepend or append) a div tag (or any other content ) in each post header -- but dont want to remove the original content.

    it seems that the filters actually replace the original function..

    something like the following pseudocode:

    function childtheme_thematic_postheader
    //my new stuff
    echo <div class='myclass' ></div>

    //then onto original content
    call original function

    add_filter( 'thematic_postheader', 'childtheme_thematic_postheader');

    Posted 9 years ago #
  2. alternatively, a way of adding a hook into THE_LOOP or post loop

    both would be good to know

    Posted 9 years ago #
  3. filters don't HAVE to completely replace content. it all depends on whether you set a new value for the variable you are passing or if you concatenate and just take more stuff on..

    see my explanation of filters:

    your example would be modified to be:

    function childtheme_thematic_postheader($postheader)
    //the $postheader variable is set to something totally new, but the original is tacked on to the end with the period
    $postheader = '<div class="myclass" ></div>' . $postheader;
    // to do it the other way and tack it to the end you'd use a period in front of the equal sign
    // $postheader .= '<div class="endclass">bacon</div>';
    //with filters you must always return the variable back to the original function
    return $postheader;
    add_filter( 'thematic_postheader', 'childtheme_thematic_postheader');
    Posted 9 years ago #
  4. oh right. i completely forgot the diff between hooks and filters. THANK YOU!

    Posted 9 years ago #
  5. btw. thanks for the bacon reference. i love bacon! little piggies are in trouble because they're so delicious.

    Posted 9 years ago #
  6. bacon rules. and makes much more delicious dummy content than lorem ipsum. don't forget to mark as resolved.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.