How to edit the caption "author" in the comments

  • Alex75017

    #49329

    Hi everyone,

    Here’s a second request for the community 🙂
    I was also wondering how to edit the label “author” that shows up when I respond to comments on my blog. Can aynone tell me which file/line I should modify to do so ?

    Again, I really looked through all the theme files but could not find a solution 🙁

    Thank you so much for your help on this matter,

    Have a good day !

    Alexandra (from Paris/France)

    Admin

    Syahir Hakim

    #49331

    Same suggestion as your other request: try using the Loco Translate plugin.

    Alex75017

    #49333

    Is there any lighter option, i try to avoid plug ins as much as possible please ?
    In Which file can i edit directly this label please ?
    Thank you so much !

    Admin

    Syahir Hakim

    #49334

    You can use a child theme instead to change the string. See the code to insert into your child theme’s functions.php file here: https://forum.graphene-theme.com/topic/changing-category-archives-title-text/#post-46130

    You can modify the theme’s files directly, but this is not recommended since the changes will not be preserved when the theme is updated.

    Alex75017

    #49361

    Hi,
    Thank you for your reply, I edited the child theme’s functions.php as mentionned (I copied and pasted the code in my file basically !) but nothing has changed unfortunately I still have the mentions “category” and “tag” before the titles 🙁

    Here’s the code of my file if you can identify any pb, I’ll be very grateful !

    <?php
    function wpm_enqueue_styles(){
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'wpm_enqueue_styles' );
    
    /**
     * Modifications Julien
     */
    
    //## Auto-update plugins
    add_filter( 'auto_update_plugin', '__return_true' );
    
    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 );
    Admin

    Syahir Hakim

    #49362

    Try this:

    function graphene_filter_gettext( $translated, $original, $domain ) {
    	$strings = array(
    		'Category: <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 );
    

    Alex75017

    #49363

    Thank you so much Syahir, it has worked this time : the word “CATEGORY” has finally been nicely removed ! 🙂 I am relieved 🙂

    I also had the same question for the word “TAG” in the archive pages, shall I just replace in the above code Category with Tag as :

    function graphene_filter_gettext( $translated, $original, $domain ) {
    	$strings = array(
    		'<strong>Tag</strong>: <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 );

    And just pasted it after the other code of the file ? or is it a different type of code ?

    Thank you so much again for your kind help !

    Admin

    Syahir Hakim

    #49364

    Instead of copying the whole block, just add a new line like this:

    function graphene_filter_gettext( $translated, $original, $domain ) {
    	$strings = array(
    		'Category: <span>%s</span>'	=> '<span>%s</span>',
    		'Tag: <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 );
    

    Alex75017

    #49365

    Thank you so much it worked beautifully ! 🙂

    In my previous post, I also asked how I could get rid of the words “filed under” in the post data before the category’s name.
    Is there another line of code I could add in the functions.php file to remove it ? Or another way ?

    Many thanks for your help !

    Admin

    Syahir Hakim

    #49372
    function graphene_filter_gettext( $translated, $original, $domain ) {
    	$strings = array(
    		'Category: <span>%s</span>'	=> '<span>%s</span>',
    		'Tag: <span>%s</span>'		=> '<span>%s</span>',
    		'Filed under %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 );
    

Viewing 10 posts - 1 through 10 (of 21 total)

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