admin管理员组文章数量:1130349
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
1 Answer
Reset to default 1This 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/
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
1 Answer
Reset to default 1This 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/
本文标签: functionshow to change quotposted byquot words
版权声明:本文标题:functions - how to change "posted by" words 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749180580a2328537.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论