Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   [SOLVED] Error:Object WP_Error could not be converted to string ... breadcrumbs ... o (http://forum.bytesforall.com/showthread.php?t=23280)

piotao Sep 12, 2015 11:02 AM

[SOLVED] Error:Object WP_Error could not be converted to string ... breadcrumbs ... o
 
Hi,
big kudos to you Flynn for Montezuma theme, I love it, and can't imagine to work with something different. This theme and your ways of solving site management defined my WP understanding. I have a site with 300+ posts, several pages and categories, etc. Since long time there is a log line which appears to show randomly and is looking like this:

Code:

[Thu Sep 10 10:57:38 2015] [error] [client 157.55.39.194] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56
[Thu Sep 10 11:38:31 2015] [error] [client 207.46.13.157] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56
[Thu Sep 10 15:25:05 2015] [error] [client 66.249.64.98] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56
[Thu Sep 10 18:26:35 2015] [error] [client 208.115.111.68] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56
[Thu Sep 10 23:00:53 2015] [error] [client 66.249.64.93] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56
[Fri Sep 11 10:00:09 2015] [error] [client 157.55.39.210] PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in /home/piotao/PKB/www/wp-content/themes/montezuma/includes/breadcrumbs.php on line 56

I'm unable to find any solution to this. I have read a similar topic here on the forum, where you had already investigated similar problem. You have said that all posts should have it's category assignement. I checked this and all of them have at least one category. However, there is no category 'Uncategorized' (I changed it's name). I suspect that some IDs could be set wrong, dunno.

Could you be so nice and find some time to help?
  • My address: http://polskikursblendera.pl
  • Montezuma 1.2.7, WP 4.3
  • My modifications include only few new virtual templates and css styles, I did not touch PHP code.
  • Plugins installed and activated: Broken link checker, Exploit scanner, Google Analitics Dashboard for WP, Growmap Anti Spambot Plugin, Hyper Cache, Justified Image Grid, List category posts, Media Library Assistant, Multi-Column Tag Map, SEO Ultimate, Simple Google Sitemap XML, T(-) Countdown, Term Management Tools, Theme Check, TinyMCE Advanced, Wordpress shortcodes, WP Show IDs.
  • Plugins installed and disabled: WP Edit, Wordpress Importer, Shortcodes Ultimate, Advanced Page Manager.

juggledad Sep 12, 2015 01:10 PM

Quote:

However, there is no category 'Uncategorized' (I changed it's name). I suspect that some IDs could be set wrong, dunno.
From my research, I would say that there is a 99% probablilty that this is the cause. I found a WP post that gave a suggestion you can try.

change line 56 from
HTML Code:

echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
to
HTML Code:

echo is_wp_error( $cat_parents = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ') ) ? '' : $cat_parents;
NOTE: this is only a bandaid for an error in your database. You could see this in many themes (any that use the 'echo get_category_parents.....code)

piotao Sep 12, 2015 02:17 PM

Thank you, I was not aware that there is such a nice function. Things seems to be nicely silenced by this nifty hack.

But if I upgrade Montezuma to the next (possibly) release, this will be lost, until I enter it again, will it not?

piotao Sep 12, 2015 02:40 PM

Hi again, the code is not exactly the same. Actually I'm writing this post the second time, because I closed a browser accidentally :(

So the code is the following:
Code:

} elseif ( is_attachment() ) {
  $parent = get_post($post->post_parent);
  $cat = get_the_category($parent->ID); $cat = $cat[0];
  echo "<li>" . get_category_parents($cat, TRUE, "</li><li>");

So as I can see, this code is executed ONLY for those posts, which have attachments. I don't have much of such posts. This code is tend to raise an error only when there is no parent! And there is obviously no parent at all when I have them in only one category. So maybe this code will be OK, if you can see and judge. I'm not a PHP developer nor I don't know the code. Is my thinking valid?

Code:

} elseif ( is_attachment() ) {
  $parent = get_post($post->post_parent);
  if(defined($parent)){
    $cat = get_the_category($parent->ID); $cat = $cat[0];
    if(defined($cat)){
      echo "<li>" . get_category_parents($cat, TRUE, "</li><li>");
    }
    else{
      echo "<li></li>";
    }
  }
  else{
    echo "<li></li>";
  }

Also I noted that your syntax in that place is a bit different than in my copy of code. Which version do you use? Maybe my Montezuma is pretty outdated?

juggledad Sep 12, 2015 04:59 PM

Quote:

if I upgrade Montezuma to the next (possibly) release, this will be lost, until I enter it again
yes it will be lost, you will have to re-fix it after each upgrade
Quote:

Also I noted that your syntax in that place is a bit different than in my copy of code. Which version do you use? Maybe my Montezuma is pretty outdated?
I used version 1.2.8 for the patch.

edit style.css and you will see the version you have. it is important to let me know so I can see what is ion line 56 of that version. My 'patch' might not be correct, however if you are on version 1.2.8 and your line 56 is not the same as mine, you might have other issues...

piotao Sep 15, 2015 01:38 AM

OK, this is strange. I have hacked that file and patch I suggested above works. The Montezuma theme has version 1.2.8 as well.

So the strange thing is that this line was not the same. I don't remember if I mess up something, but nevertheless after last upgrade it should be cleaned. Maybe this file is not update with the update? Dunno.

This repair works, so thank you anyway, your help is valuable and much appreciated!


All times are GMT -6. The time now is 08:49 PM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.