Title: Fix qTranslate with WordPress 3.9
Author: Alex Kirk
Published: April 17, 2014
Last modified: December 1, 2016

---

# Fix qTranslate with WordPress 3.9

April 17, 2014

When updating a blog of mine to WordPress 3.9 the page wouldn’t load anymore because
of [qTranslate](http://www.qianqin.de/qtranslate/) not able to cope with the update.
In the error log it says:

`PHP Catchable fatal error: Object of class WP_Post could not be converted to string
in ../wp-content/plugins/qtranslate/qtranslate_core.php on line 455

The error is caused by this change: [get_the_date() to accept optional $post argument](https://core.trac.wordpress.org/ticket/13771)

There is [a proposed quick fix](http://zioproto.ninux.org/wordpress/2014/04/17/dirty-and-quick-fix-for-qtranslate-plugin-on-wordpress-3-9/)
by [Saverio Proto](http://zioproto.ninux.org/), but it doesn’t take the problem 
at its root:

qTranslate registers the function qtrans_dateFromPostForCurrentLanguage($old_date,
$format ='', $before = '', $after = '') for the hook get_the_date but it actually
[only accepts one parameter](http://codex.wordpress.org/Function_Reference/get_the_date).
With the new update it accepts a second parameter $post, which now wrongly fills
the variable $before that is in the process being converted to a string.

So [the solution](https://gist.githubusercontent.com/akirk/10979790/raw/3b2b37b399a82dc82723fb6b8e703c1d981b26f9/qtranslate_core.php.diff)
simply is to delete the two parameters that were assigned the wrong meaning and 
have defaults anyway.

[Web](https://alex.kirk.at/category/web/)

Read this next

[Zapier would be such a…](https://alex.kirk.at/2014/03/04/zapier-would-be-such-a/)

## 9 responses to “Fix qTranslate with WordPress 3.9”

 1.  ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
     06/cropped-2025.Alex-512x512-1-48x48.jpg)
 2.  [Alexander Kirk](http://alex.kirk.at/)
 3.  [April 26, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84075)
 4.  Nothing spectacular, just ahead of the line with the error message I added a `
     var_dump($before);` to see that the content of the variable is an object instead
     of a string, then I checked the [Codex](http://codex.wordpress.org/Function_Reference/get_the_date)
     to see the parameters of the function being called.
 5.  [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 6.  ![Daniela Avatar](https://secure.gravatar.com/avatar/380112dfc6a3fa11fc7836cb87d7e3c292084ee3fed4b42cb38c4bd81eb58fa7?
     s=48&d=mm&r=g)
 7.  [Daniela](http://www.happytravels-puravida.com)
 8.  [April 26, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84093)
 9.  Hi there! IÂ´m pretty new to WordPress and especially to working with github. 
     So my question is: Is it correct to download the gist code you offered, then extract
     the file in it and upload it on my FTP to the qtranslate folder? This is what 
     I did, but I still get the error message on my website like before: CATCHABLE 
     FATAL ERROR: OBJECT OF CLASS WP_POST COULD NOT BE CONVERTED TO STRING IN /HOME/.
     SITES/698/SITE8704257/WEB/WP-CONTENT/PLUGINS/QTRANSLATE/QTRANSLATE_CORE.PHP ON
     LINE 455
 10. What am I doing wrong?
 11. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 12.  a. ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
         06/cropped-2025.Alex-512x512-1-48x48.jpg)
      b. [Alexander Kirk](http://alex.kirk.at/)
      c. [April 27, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84096)
      d. The file shows what needs to be changed. Either you can use the program called`
         patch` or, as this is a quite simple change, simply do what is shown using a 
         text editor: remove the red line and add the green line (or just modify the line
         so that it looks like the green line afterwards).
      e. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 13. ![Toni Avatar](https://secure.gravatar.com/avatar/2c771ea373aa8e053fed29b682bafc19c02c2fd2577c093776d1532ccf65164e?
     s=48&d=mm&r=g)
 14. [Toni](http://blog.jethro.fi)
 15. [April 27, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84100)
 16. To the point! A good quick fix for the problem. Good that you also explained the
     root cause. I’m still wondering why the $before and $after are added to the function
     parameters and not outside of it?
 17. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 18. ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
     06/cropped-2025.Alex-512x512-1-48x48.jpg)
 19. [Alexander Kirk](http://alex.kirk.at/)
 20. [April 27, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84101)
 21. What do you mean? The function `qtrans_dateFromPostForCurrentLanguage` provides
     a $before and $after parameter when the WordPress API doesn’t ask it to provide
     it. When WordPress changed their API by adding parameters, the $before variable
     now gets some unexpected content (which previously always was an empty string,
     because of the default value `$before = ''`)
 22. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 23. ![Sandrine Marquis Avatar](https://secure.gravatar.com/avatar/f7bc7987b35c3a7b14baaef99c94ab965722e6b91b82ae6f80ea707e0296784f?
     s=48&d=mm&r=g)
 24. [Sandrine Marquis](http://sandmarq.ca/)
 25. [April 28, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84103)
 26. Works fine except two little detail. It’s breaking my nextgen gallery plugin.
 27. Now it’s telling me : Invalid Displayed Gallery Works fine if I disable qtranslate
     plugin.
 28. And the editor still not properly working.
 29. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 30. ![Recursos Web Avatar](https://secure.gravatar.com/avatar/f9db9895b9e4596a18aab874b71d575d5aa4f0b6b7a47b30fd6014870f0568ce?
     s=48&d=mm&r=g)
 31. [Recursos Web](http://http://www.recursosweb.es)
 32. [April 29, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84106)
 33. Thank you very much! Solved! :-)
 34. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 35. ![Milan Avatar](https://secure.gravatar.com/avatar/937a21636f51cf6b3d306f6dae9f2aed3071d12a5c03f8f5f8eba770d5b4b407?
     s=48&d=mm&r=g)
 36. [Milan](http://www.vozes-do-brasil.de)
 37. [April 29, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84107)
 38. Hi,
 39. fix is working for me, but all the headlines are gone ? :-/
      Anyone, any idea?
 40. thanks in advance for help…
 41. Milan
 42. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)
 43.  a. ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
         06/cropped-2025.Alex-512x512-1-48x48.jpg)
      b. [Alexander Kirk](http://alex.kirk.at/)
      c. [April 29, 2014](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/#comment-84108)
      d. For all other problems it might be worth trying to switch to [mqtranslate](http://wordpress.org/plugins/mqtranslate/),
         a more actively maintained qtranslate fork.
      e. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2014%2F04%2F17%2Ffix-qtranslate-with-wordpress-3-9%2F)

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2014/04/17/fix-qtranslate-with-wordpress-3-9/comment-page-1/?output_format=md#respond)󠁿

Only people in [my network](https://alex.kirk.at/friends/) can comment.

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)