Why do I get an error message on Wordpress blog posts (only) on my local environment (and on the original server I don't)
The warning is regarding the following part of your code: __( )
.
In WP __
is actually a function for translation purposes.
From a short look in the manual, we can see that the __()
function usage is:
<?php $translated_text = __( $text, $domain ); ?>
And that the $text
parameter is required.
$text (string) (required) Text to translate. Default: None $domain
(string) (optional) Domain to retrieve the translated text. Default: 'default'
In your code, you don't send any argument to that function and therefore you're getting a legit warning. To be honest, I don't know why there was no argument in the first place. Moreover, also your remote server should show that warning. In case it doesn't - or the code is different or you have error_reporting(0)
somewhere on the server (php.ini / wp-config.php).
A simple solution would be just to add an empty string as an argument.
Try putting this in your wp-config.php, this doesn't solve the issue but this is basically the difference between your server and your local.
error_reporting(0);
It's a warning and you can suppress it, its not an error.
To solve the issue, you will need to pass a string to__()
function because it expects a string to be passed. Read more here: https://codex.wordpress.org/Function_Reference/_2