Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Change ’wrote a new blog post’ text.


  • alienjackhammer
    Participant

    @alienjackhammer

    Is there a way to change the text when posting? I’d like to get rid of “Joe Pupperstein wrote a new blog post” and simply replace it with: “Joe Pupperstein wrote: “

    Possible?

Viewing 5 replies - 1 through 5 (of 5 total)

  • @mercime
    Keymaster

    @mercime

    For this text string, you can use Westi’s method at http://blog.ftwr.co.uk/archives/2010/01/02/mangling-strings-for-fun-and-profit/

    You can add the following code in your theme’s functions.php

    `<?php

    /* http://blog.ftwr.co.uk/archives/2010/01/02/mangling-strings-for-fun-and-profit/ */

    class PJW_Translation_Mangler {

    function filter_gettext($translation, $text, $domain) {
    $translations = &get_translations_for_domain( $domain );
    if ( $text == ‘%s wrote a new blog post: %s’ ) {
    return $translations->translate( ‘%s wrote: %s’ );
    }
    return $translation;
    }
    }
    add_filter(‘gettext’, array(‘PJW_Translation_Mangler’, ‘filter_gettext’), 10, 4);

    ?>
    `


    alienjackhammer
    Participant

    @alienjackhammer

    Thanks a ton!


    @mercime
    Keymaster

    @mercime

    You’re welcome.

    @mercime oh awesome! needed that.

    I adapted it a little, to display a link to the category the post is in (assuming one category, and category slug of ‘category’) :

    `class PJW_Translation_Mangler {

    function filter_gettext($translation, $text, $domain) {
    global $post;
    $category = get_the_category($post->ID);
    $cat_slug = $category[0]->slug;
    $category = $category[0]->cat_name;
    $translations = &get_translations_for_domain( $domain );
    if ( $text == ‘%s wrote a new blog post: %s’ ) {
    return $translations->translate( ‘%s wrote a new post: %s, in ‘.$category.’‘);
    }
    return $translation;
    }
    }
    add_filter(‘gettext’, array(‘PJW_Translation_Mangler’, ‘filter_gettext’), 10, 4);`

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Change ’wrote a new blog post’ text.’ is closed to new replies.
Skip to toolbar