Custom Taxonomy change text "Category Archive" on Category pages to be the Category Title

  • carrie01

    #5126

    I have used the following function provided by Syahir in a previous post:

    function graphene_filter_gettext( $translated, $original, $domain ) {
    $strings = array(
    'Category Archive: <span>%s</span>' => '<span>%s</span>',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );

    How can I get this to work for custom taxonomies as well?

    Anonymous

    #30758

    What is the url where your custom taxonomy is displayed?

    Admin

    Syahir Hakim

    #30759
    function graphene_filter_gettext( $translated, $original, $domain ) {
    $strings = array(
    'Category Archive: <span>%s</span>' => '<span>%s</span>',
    '%1$s Archive: %2$s' => '%2$s',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );

    carrie01

    #30760

    I have tried pasting this code into my child theme but it came up with this error:

    Parse error: syntax error, unexpected ‘%’ in C:wampwwwwp-contentthemesgraphene-childfunctions.php on line 14

    How can I get back into my site to try again? My site is on localhost.

    ronangelo

    #30761
    Quote:
    How can I get back into my site to try again? My site is on localhost.

    just manually edit the the code you added in graphene-childfunctions.php.

    Admin

    Syahir Hakim

    #30762

    I’ve corrected the code above. It was missing the single quotes.

    carrie01

    #30763

    Thank you both so much. It’s all working!

Viewing 7 posts - 1 through 7 (of 7 total)

  • You must be logged in to reply to this topic.