$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - how to change "posted by" words|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - how to change "posted by" words

matteradmin8PV0评论

How do I change the words "posted by" and "on" that show on top of each WP post, to my own language? For example I want to change this:
Posted by محمد on 6 نوفمبر 2018, 12:22 م
to:
كتبه محمد في 6 نوفمبر 2018, 12:22 م

I'm using a custom functions plugin, so I can add the code that you provide.

How do I change the words "posted by" and "on" that show on top of each WP post, to my own language? For example I want to change this:
Posted by محمد on 6 نوفمبر 2018, 12:22 م
to:
كتبه محمد في 6 نوفمبر 2018, 12:22 م

I'm using a custom functions plugin, so I can add the code that you provide.

Share Improve this question asked Nov 14, 2018 at 11:10 MuhammadMuhammad 611 gold badge1 silver badge5 bronze badges 1
  • This likely isn't something that can be changed in a custom functions plugin. It would be part of your theme's templates. – Jacob Peattie Commented Nov 14, 2018 at 11:12
Add a comment  | 

1 Answer 1

Reset to default 1

This can MOST LIKELY be done with the get_text filter. Here's an example (and then some caveats):

function my_theme_text_switcher( $translations, $text, $domain ) {

    if ( $domain == 'my-theme' && $text == 'posted by' ) {
        $translations = __( 'YOUR TEXT HERE', 'my-theme' );
    }

    if ( $domain == 'my-theme' && $translations == 'on' ) {
        $translations = __( 'YOUR TEXT HERE', 'my-theme' );
    }

    return $translations; } 
add_filter( 'gettext', 'my_theme_text_switcher', 10, 3 );

Now the caveats:

  • Go to your theme and find the single.php template and look for the post markup where those words are output. IF they are output with proper internationalization then the snippet above will work. It'll look something like this: __('post by', 'my-theme');
  • If that is there correctly, look for that second part the "my-theme" part. That is your theme's translation domain. You need to use that in the function correctly.
  • IF, on the other hand, that text is hard-coded in your template files, then you can override it with a child theme. Read about Child Themeing here: https://mediatemple/blog/tips/best-practice-why-and-how-to-create-a-child-theme-in-wordpress/
Post a comment

comment list (0)

  1. No comments so far