How to Fix “Catchable Fatal Error Object of Class WP_Error Could Not Be Converted to String” in WordPress

Hey guys, I experienced this message the other day “catchable fatal error object of class wp_error could not be converted to string” while trying to access my website. I really had a scare because I was trying everything there is on the internet and none of the forums or websites could bring me a solution to my problem. Also, I contacted my hosting company and due to the volume of calls, it took ages to get through so I had to took matters in my own hands.

See: WP Super Cache Tester Pages Do Not Match Fix

Description of the Error

When I type my URL in my browser, I got this exact message, “Catchable fatal error: Object of class WP_Error could not be converted to string in /home1/*********/public_html/wp-includes/default-constants.php on line 135” as seen in the screenshot below.

Note: The asterisks is for security reasons.

object of class wp_error could not be converted to string

Then I decided to go into my cPanel to check the default-constants.php file at line 135 in the wp-includes folder. The code that I saw in the file can be seen below:

function wp_plugin_directory_constants() {
        if ( !defined(‘WP_CONTENT_URL’) )
                  define( ‘WP_CONTENT_URL’, get_option(‘siteurl’) . ‘/wp-content’); // full url – WP_CONTENT_DIR is defined further up

Note: The problem is not in the default-constants.php, so do not edit or modify the code in the file.

What Caused the Catchable Fatal Error?

What really caused the catchable Fatal Error is that my site URL and home address is not pointing to each other in my server’s database. When I logged into my database, I saw my siteurl pointing to some gibberish (O:8:”WP_Error”:2:{s:6:”errors”;a:1:{s:30:”wpdb_get_table_charset_failure”;a:1:{i:0;s:0:””;}}s:10:”error_data”;a:0:{}}) and my home pointing to (https://www.msgdigital.com). To correct this, they should be both pointing to https://www.msgdigital.com.

Steps to Fix Catchable Fatal Error: Object of Class WP_Error Could Not Be Converted to String

I know your anticipating this section to solve this issue quickly because you probably losing money or traffic at the moment. So, here’s the exciting part.

Note: Some parts in the screenshots are blurred for security reasons.

  1. Log into your cPanel and click phpMyAdmin.
  2. Select your database (it is located on the left-hand side).
  3. From the drop-down list of tables, click the wp_options tableobject of class wp_error could not be converted to string
  4. Look for siteurl and home on the right-hand side, make sure they are both pointing to your domain (e.g. https://www.msgdigital.com). I had some gibberish in my siteurl so I click Edit to change it. catchable fatal error object of class wp_error could not be converted to stringcatchable fatal error object of class wp_error could not be converted to string
  5. When you are finish entering your url, click Go.

That’s it guys! That is how I fix catchable fatal error: object of class wp_error could not be converted to string. If you have other ways on how to fix this issue, you can share it with us in the comment section below. Also, if you like my articles you can subscribe to my blog and like my Facebook page by clicking this link. Thank you.

16 COMMENTS

  1. I hadn’t been working on my website, done any updates or anything at all when I suddenly encountered this error. Perhaps I had been compromised. I changed passwords just in case. I discovered the error message that led me here via my Plesk dashboard.

    Anyway, whatever the cause, your solution saved my neck today. Thank you.

    • You’re welcome Sam and it’s good to know that it helps. There are times when it will occur again even though you have updated WP and your plugins. So, if it do, you can use this method to resolve this issue.

  2. Okay, I tried accessing a certain website (not naming which) on my Wii U and this message popped up. Is this website now completely unaccessable or is this fixable?

    • No I didn’t Pierre, from I modified it in wp_options. You told me you were going to do more research to see if there’s a permanent solution to this problem. Did you find any?

      Oh and remember to subscribe for more WordPress fix in the future 🙂

  3. Thanks Wayne for your answer. I don’t modify my website for several day.
    I have to modify the siteurl in the wp_options as your post suggested. But after 2 hours, the problem appears again.
    I modify the password of phpmyadmin and it seems to be OK now.
    I care that the problème isn’t fixe…
    I continue my research 😉

    • Thanks for notifying me about the change of password part Pierre. I guess I’ll try that method to see if it works because it happen to me again about three weeks after that. When you do your research and find a solution please let me know 🙂

    • Thanks Pierre for your comment. I’m not sure why the change in the database. But what I do know is that this Catchable Fatal Error started to occur when I was improving my website in a new installation to work on it. When I’m finished, I transferred the files over to public_html and delete the database of the website I was working on. That’s when I started to get this error.

Share your thoughts on this topic