[wp-hackers] Replacing Hooks/Functions

Rob Miller r at robm.me.uk
Mon Jul 3 21:07:51 GMT 2006


Computer Guru wrote:
> Does that work?
> I mean, the_content() is a function called that will return data... if I
> add a hook to this, won't it modify the _data_ that the_content() puts out?
function foo() {
   return 'blah';
}
add_action('the_content', 'foo');

Yes, it's modifying the output but it's essentially as if you've made 
your own the_content() function. You can get a value from the database 
or do whatever you like in foo() and it will be as if it happened in 
the_content().

David Chait wrote:
> the_content grabs the post/page content, then calls do_filter('the_content', 
> $content).  so if your plugin is the highest priority, you can 'nuke' the 
> 'incoming' content, and replace it with anything.
>   

You'll probably want it running at the lowest priority, so that your 
output isn't modified by other plugins who think it's actually 
the_content - unless you want that to happen, of course.

-- 
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/



More information about the wp-hackers mailing list