1

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.

1

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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