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.

Just wondering how to filter to change the current page title from a shortcode,

Since shortocodes are rendering after $post.

any idea to archieve something like : do_shortcode(['mytitle="newtitle"']);

share|improve this question

1 Answer 1

up vote 1 down vote accepted

why not to use the_title filter?

add_filter('the_title', 'the_title_filter');
function the_title_filter($title){
    $post = get_post(get_the_id());
    //enter code here
    return $title;
}

as for shortcode - its imposible. in logical way - imposible.

share|improve this answer
    
can you explain better? why is impossible? –  greenbandit Mar 26 '12 at 20:21
1  
It's impossible because the title has already been generated before shortcodes are parsed. –  EAMann Mar 26 '12 at 20:49
    
You could allow shortcodes for the title (like for anything else) too. Not that it would make much sense. –  kaiser Mar 26 '12 at 23:47

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.