Support » Theme: Twenty Twelve » Overriding twentytwelve_wp_title in a child theme

  • Resolved eVolts



    I’m trying to override the twentytwelve_wp_title function in a child theme to remove the site description and use a different separator, but it’s not possible.
    How can I do this without using a modified header.php?
    May the twentytwelve_wp_title function be pluggable in a future version?


Viewing 4 replies - 1 through 4 (of 4 total)
  • no need for the function to be pluggable, as it is added as a filter function;
    see: add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

    remove it from the filter, and add your own function.

    Hi alchymyth,

    thanks for your answer!
    So I’ve to remove it from inside myown_wp_title function? Because I can’t remove it from my functions.php file, since is loaded before the parent one.
    This a overhead of add and remove of functions, isn’t it?


    this for example works for me, in a child theme of Twenty Twelve:

    function adjust_twentytwelvechild_wp_title() {
    	remove_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
    	add_filter( 'wp_title', 'twentytwelvechild_wp_title', 10, 2 );
    function twentytwelvechild_wp_title( $title, $sep ) {
    	global $paged, $page;
    /*your wp_title code here*/
    	return $title;

    Thanks alchymyth, I’ll go this way.

    Just for the records, I still think this is an overhead of function calling, that can be avoided just making the twentytwelve_wp_title function pluggable.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Overriding twentytwelve_wp_title in a child theme’ is closed to new replies.