Forums

'Correct' way to override parent theme functions in theme frameworks (3 posts)

  1. blogjunkie
    Member
    Posted 2 years ago #

    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.

  2. Justin Tadlock
    Member
    Posted 2 years ago #

    There are support forums that deal specifically with that theme.

  3. venutip
    Member
    Posted 2 years ago #

    This might be getting to you a little late, but I had this same question myself and tried to answer it on my blog.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Topic