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 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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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:

<?php
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.

share|improve this answer
    
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

 
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.