Why am I getting an error in Wordpress blog posts (only) in my local environment (and on the source server I don't)

I copied all my WP files from server to my local WAMP as dev environment. Everything works smoothly except when viewing a blog post.

I am getting a good result from all titles / categories / post-content / ect '- But with a weird output before the blog content:

http://i.stack.imgur.com/JTKJ5.png <code> enter image description here </code>
        <script async src=
" data-src="/img/6f820d26050a18c72ec544229fe62137.png" class=" lazyloaded" src="https://fooobar.com//img/6f820d26050a18c72ec544229fe62137.png">

content.php Line 68 is a piece of code: __( ),

One line after the "the_content" function:

<div class="post-bottom">
    <div class="post-text-container">
            /* translators: %s: Name of current post*/
            $postURL = get_permalink();
            $commentsURL = get_comments_link();
            the_content( sprintf(
                __(  ),
                the_title( '<span class="screen-reader-text">', '</span>', false )
            ) );
            if ( !is_single() ) :
                    echo "<div class=\"read-more\"><a href=\"$postURL\">Continue reading...</a> | <a href=\"$commentsURL\">Full Comments</a></div>";


What could be causing this?

Edit: The only thing I changed was when I copied stuff to my local server:

1 - I copied my database to my local phpmyadmin and changed everything http://www.example.com

to http://localhost/example

in the options table.

2 - I completely deleted my .htaccess file (and Wordpress generated a new one myself)

This is how it looks on the server:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress


and this is what I have locally:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]

# END WordPress


3- I have enabled "rewrite_modle" in WAMP because it is disabled by default.


source to share

2 answers

Warning covers the next part of your code: __( )


WP __

is actually a function for translation purposes.

From a quick overview in the manual, you can see that using the function __()


<?php $translated_text = __( $text, $domain ); ?>


And what a parameter is required $text


$ text (string) (required) Text to translate. Default: No $ domain

(string) (optional) Domain to receive the translated text. Default: 'Default'

In your code, you are not sending any arguments to this function, and therefore you get a legitimate warning. To be honest, I don't know why there were no arguments at all. Also, your remote server should show this warning. If it is not - either the code is different or you have error_reporting(0)

it somewhere on the server (php.ini / wp-config.php).

A simple solution would be to just add an empty string as an argument.



Try putting this in your wp-config.php, it won't solve the problem, but it's basically the difference between your server and your local one.



This is a warning and you can suppress it, it is not a bug.

To solve the problem, you need to pass a string to the function __()

because it is waiting for a string to be passed. More details here: https://codex.wordpress.org/Function_Reference/_2



All Articles