Support » Themes and Templates » ‘Correct’ way to override parent theme functions in theme frameworks

  • I’m building a child theme off the Hybrid framework, and my question is how to override the Hybrid parent theme functions the ‘correct’ way in functions.php. Details follows:

    Here’s the bit of Hybrid theme function that generates the entry title:


    function hybrid_entry_title() {

    if ( is_attachment() )
    $title = the_title( '<h1 class="attachment-title entry-title">', '</h1>', false );

    elseif ( is_page() )
    $title = the_title( '<h1 class="page-title entry-title">', '</h1>', false );

    elseif ( is_single() )
    $title = the_title( '<h1 class="single-title entry-title">', '</h1>', false );

    else
    $title = the_title( '<h2 class="post-title entry-title">', '</h2>', false );

    echo apply_filters( 'hybrid_entry_title', $title );
    }

    In my child theme, I want to override this so I do this in the child theme’s functions.php file:


    function childtheme_entry_title() {
    .. my custom code here ..
    echo apply_filters( 'childtheme_entry_title', $title );
    }
    add_action( 'hybrid_before_entry', 'childtheme_entry_title' );

    Now, I get 2 entry titles on my posts – 1 from the Hybrid functions and 1 from my child theme functions.

    How do I override the hybrid_entry_title() function with my childtheme_entry_title and still use the hybrid_before_entry hook?

    Thanks in advance, PHP gurus.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘‘Correct’ way to override parent theme functions in theme frameworks’ is closed to new replies.