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

1 Answer 1


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? Commented Mar 26, 2012 at 20:21
  • 1
    It's impossible because the title has already been generated before shortcodes are parsed.
    – EAMann
    Commented Mar 26, 2012 at 20:49
  • You could allow shortcodes for the title (like for anything else) too. Not that it would make much sense.
    – kaiser
    Commented Mar 26, 2012 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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