0

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"']);

2

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.

  • 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

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.