I hope this question is easy. I want to customize my theme so that the post titles are created on the fly with code. For example, I might have a post where a price changes on the page 4 times a week, and I want to be able to change my to say: Get Product X for $19.99 without having to manually edit a meta variable...

Is it possible to do?

Is there a wordpress function I can call to override the title using a plugin?


I can't answer how you'll get your dynamic data with which to update your Post Title, but you can easily hook into the Post Title, using the the_title filter:

function mytheme_dynamic_title( $title ) {
     // do something to the Post Title, which is passed
     // into this function as the variable $title
     // and then return $title
     return $title;
add_filter( 'the_title', 'mytheme_dynamic_title' );

That should get you started with hooking into the Title.

  • Thanks, that looks perfect to me. I knew there must be something straight forward. To get the custom content for the title, I'm running my own plugin which I think I can just add this to customize what I need. Thanks again! – Dave Johnshon May 5 '11 at 2:23

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.