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

1 Answer 1

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.

3
  • can you explain better? why is impossible? Mar 26, 2012 at 20:21
  • 1
    It's impossible because the title has already been generated before shortcodes are parsed.
    – EAMann
    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
    Mar 26, 2012 at 23:47

Your Answer

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

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