Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have added the code below to an active plugin, but it's having no effect on my posts.

add_filter( ‘the_title’, ‘myfunction’);

function myfunction($title) {
 return "Why won't this work?" . $title;
}

What am I missing here?

The post templates are definitely using the_title(), and the theme is normal (wp_head(), etc), and there are no conditionals surrounding the function in the plugin that would make it not run. I have also tried adding different priority in the add_filter function, from -9999 to 9999, to no effect.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try changing this:

add_filter( ‘the_title’, ‘myfunction’);

to this:

add_filter( 'the_title', 'myfunction' );

(If this is indeed your problem it is likely an issue of copy/pasting code from a tutorial with curly quotes in place of standard single-quote marks.)

p.s. prefix your function name with your Plugin slug. "myfunction" is far too generic.

share|improve this answer
    
Curly quotes was it! I was going mad trying to figure that out. –  supertrue Jul 10 '11 at 20:48
    
(Oh, and myfunction isn't the real function name.) –  supertrue Jul 10 '11 at 20:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.