[wp-hackers] Hooks, Actions, Filters

Bruno Alexandre bruno.in.dk at gmail.com
Wed Jul 29 06:38:21 UTC 2009


Howdy Guys,
I'm quite new to this,m and I wanted to understand the Hooks and Filters
better, I can't get it right from Codex.

I did a simple test,

the idea is to override the get_title() method in order to erase the
"Protected: " sentence from the title if the page is protected, there is a
protected_title_format filter, and I thought using it ...


that line in post-template.php specifies:

$protected_title_format = apply_filters('protected_title_format',
__('Protected: %s'));


for what I could get from CODEX, I need to remove that filter and add my
own, like


remove_action('protected_title_format');
apply_filters('protected_title_format', __('MY OWN PAGE Protected: %s'));

using, off course something like


// Removing action function remove_title_action() {
remove_action('protected_title_format','get_the_title',3); }
add_action('init','remove_title_action'); // Adding custom function
add_action('protected_title_format','fancy_title', 3, 4); function
fancy_title($id = 0) { $post = &get_post($id); $title = $post->post_title;
echo "I'm the king of the world!... >" . $title . "< & >" . $post . "<"; if
( !is_admin() ) { if ( !empty($post->post_password) ) {
$protected_title_format = apply_filters('protected_title_format', __('MY OWN
PAGE Protected: %s')); $title = sprintf($protected_title_format, $title); }
} return apply_filters( 'the_title', $title, $post->ID ); }



I can get the echo to output, but I dont get the $id, this method is a copy
of get_title() stripping out everything but the protected part


Can anyone care to explain me how this works?
Thank you

Bruno Alexandre
[web] www.balexandre.com
[twitter] http://twitter.com/balexandre


Jonathan Swift<http://www.brainyquote.com/quotes/authors/j/jonathan_swift.html>
- "May you live every day of your life."


More information about the wp-hackers mailing list