Some time ago, Qian Qin, the author of qTranslate, has published what should be modified on the Google (XML) Sitemaps Generator WordPress Plugin to make it support qTranslate.
However, this has never reached any of the releases of this plugin. (Qian Qin says he sent an e-mail to the author and I’ve done it myself, with no response).
So, I’m going to publish what should be modified on the plugin (for the ones who may want to do them themselves) and then, leave the link to download the modified version I prepared. I’ll be updating it for each new release.
Update: I’ve made some code corrections myself to include the different translations of the home page and not to include the entries not written in the default language (just include the written languages). The download and the code snippets have been updated to reflect the changes. If you wish more details, please go to the post of the update.
Update (2009-09-30): I’ve updated the naming of the plugin at the WordPress repository and the support for blogs without qTranslate installed. For releases before the 3.1.6.3, you may get notified for the original version updates (and not for this version supporting qTranslate), so I really recommend updating. If you wish more details, please go to the post of the update.
First, the changes… They are all made in the sitemap-core.php file…
Change 1
Original version:
//Add the home page (WITH a slash!) if($this->GetOption("in_home")) { if('page' == get_option('show_on_front') && get_option('page_on_front')) { $pageOnFront = get_option('page_on_front'); $p = get_page($pageOnFront); if($p) { $homePid = $p->ID; $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } } else { $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } }
Modified version:
//[NeoEGM] Moved here for home page support for different languages $useQTransLate = function_exists('qtrans_convertURL') && function_exists('qtrans_getAvailableLanguages'); global $q_config; //Add the home page (WITH a slash!) if($this->GetOption("in_home")) { if('page' == get_option('show_on_front') && get_option('page_on_front')) { $pageOnFront = get_option('page_on_front'); $p = get_page($pageOnFront); if($p) { $homePid = $p->ID; $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home")); //[NeoEGM] Home page support for different languages if($useQTransLate) foreach($q_config['enabled_languages'] as $language) if($language != $q_config['default_language']) $this->AddUrl(qtrans_convertURL( trailingslashit($home), $language, true), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } } else { $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home")); //[NeoEGM] Home page support for different languages if($useQTransLate) foreach($q_config['enabled_languages'] as $language) if($language != $q_config['default_language']) $this->AddUrl(qtrans_convertURL( trailingslashit($home), $language, true), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } }
Change 2
Original version:
$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
Modified version:
//[NeoEGM] Line removed //$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
Change 3
Original version:
//Add it $this->AddUrl($permalink,$this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage?$cf_pages:$cf_posts), $prio);
Modified version:
//Add it //[NeoEGM] Add it only if the default language is defined, otherwise only add the defined languages $QTranslateLanguages = qtrans_getAvailableLanguages($post->post_content); if (in_array($q_config['default_language'], $QTranslateLanguages)) $this->AddUrl($permalink, $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage?$cf_pages:$cf_posts), $prio);
Change 4
Original version:
// Multilingual Support with qTranslate, thanks to Qian Qin if ($useQTransLate) { global $q_config; foreach (qtrans_getEnabledLanguages($post->post_content) as $language) { if ($language != $q_config['default_language']) { $this->AddUrl(qtrans_convertURL($permalink, $language), $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage ? $cf_pages : $cf_posts), $prio); } } }
Modified version:
//Multilingual Support with qTranslate, thanks to Qian Qin //[NeoEGM] Moved up the global variable scope line if ($useQTransLate) foreach (qtrans_getAvailableLanguages($post->post_content) as $language) if ($language != $q_config['default_language']) $this->AddUrl(qtrans_convertURL($permalink, $language, true), $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage ? $cf_pages : $cf_posts), $prio);
Download modified plugin version
Now, finally, the link…
Support appreciated!
All the content offered in this website is, except noted otherwise, of free nature. This means you can share it wherever you want if you do it freely and stating its source.
If it was useful for you and you’d like to contribute, you can make a donation or, at least, visit one of our advertisers of your choice; they are all around the site.
Incoming search terms for the article:
- qTranslatesupportfortheGoogle(XML)SitemapsGeneratorWordpressPlugin|NeoEGM com
- qtranslate
- neoegm
- Please edit wp-db inc php in wp-includes and set SAVEQUERIES to true if you want to see the queries
- google xml sitemap
- Google XML Sitemaps with qTranslate Support
- wp-db inc php
- qtrans_convertURL
- wordpress sitemap qtranslate
- qtranslate google
Sorry but the plugin you have patched seems to have some problems:
if a post is published only in one language out of the default, the sitemap will contain two URLs, one pointing to the correct post version, one pointing to the wrong default language:
example, at mysite.com, default language EN (english) , and additional language DE (german), there’s a post with permalink “a-german-post”; in sitemap.xml you have:
http://mysite.com/de/a-german-post (CORRECT)
but also
http://mysite.com/a-german-post (WRONG)
Check it out
Hi Blutarsky!
Thanks for your comment!
First of all, just as I said in the post, I haven’t made the patch myself… I’ve only integrated it with the latest plugin version since its author was not taking care of the sent mails…
It’s completely logical what you’re saying and I hadn’t found it since I’ve always written every post in both languages…
I’ll check it and publish a new patched version soon!
I’ll make a new post to notify the availability of the new version, so if you’re subscribed to the RSS, you’ll know as soon as I release it… Otherwise, take a look to the site frequently…
Greetings!
NeoEGM.
Thanks for helping! Why not adding the “subscribe to comments” plugin to your blog? 😉
You’re welcome
I will! But I have some things to configure on my mail server… That’s why I haven’t done it yet!
Thanks for the suggestion!
NeoEGM.
BTW, I’m stuck with sitemap generation 😐 ….do you have any scheduled date for the next release?
Don’t worry! I’ll prepare it within these days… I’ll release it this weekend! Probably today or tomorrow…
Greetings!
NeoEGM.
Done, I’ve just updated the plugin.
Now it works as you expected
Also, I added the support for the home page in different languages. It always get added in all the available languages.
Enjoy it!
NeoEGM.
Will be testing it now! Thanks mate!
Yes! You did it! Thumbs up!
Excellent!
Enjoy it
NeoEGM.
Two questions.
1) How do I know I have patched correctly the oroginal plugin? Is there any evidence in the admin panel?
2) Is there a comfortable way to upgrade the plugin? I think it basically depends on the plugin itself, if it performs some database operation while upgrading; if not it’s just an upload matter…. can you confirm?
Hi! I was just analyzing which was the best way to do that…
1- No, there is no evidence by now. I’ll add some kind of legend to the plugin description.
2- There is no database extra-work in the patched plugin, it’s just matter of replacing the plugin files. Anyway I’m thinking of publishing the patched plugin in the WordPress repository in order to allow the automatic upgrading.
Greetings!
NeoEGM.
Great, because at the moment either you need to delete the plugin (maybe loosing settings) and install your patched version, or you can brute-force upload your plugin with an FTP-like program, rewriting current data….
No uninstall is needed, just overwritting the files via http://FTP...
No settings are lost…
Anyway, I’ll be easier to just have a patched plugin in the repository and be able to install it directly and upgrade it automatically!
I’ll tell you when I release it!
NeoEGM.
Just as I promised some time ago, I’ve just published the plugin in the WordPress Repository.
You can now download the latest version from here and you’ll get notified by WordPress when I release a newer version.
Enjoy it
NeoEGM.
Has anything changed for those who doesn’t use qTranslate? I mean should I update the plugin if I don’t use qtranslate?
Not by now… The only current difference beween this version and the original one is the qTranslate support…
Thanks for your question!
NeoEGM.
hi there. having a problem with your plugin and google webmaster tools. reported it here in the wordpress forums: http://wordpress.org/support/topic/314704?replies=0
any ideas? google is saying my links are broken but hey are jsut fine !?
Hi ovidiu!
Perhaps, when Google visited your site, it was down or busy and some of your links became “broken” because of that…
Check the “detection” date in Webmaster Tools…
I don’t think the plugin has anything to do with that… It just lists the URLs in your site…
Check something, open http://www.example.com/sitemap.xml (replacing “example” with your site’s domain) and click randomly your links. You’ll see they are not broken.
Other option is that Google is declaring as broken some links not on your sitemap. For example, bad external links or changed permalinks obtained from somewhere else.
That’s all!
Hope it helps!
NeoEGM.
the site was up, no problems there. I even resubmitted and got the same results
will give it one more try, and yes, I know the links inside the sitemap are working….
besides there are no broken external links either, and google specifically complained about the links inside the sitemap, decalred all 76 of the broken
Hi ovidiu!
I’ve just checked your robots.txt file…
This is its content:
# BEGIN XML-SITEMAP-PLUGIN
Sitemap: http://pacura.ru/sitemap.xml.gz
# END XML-SITEMAP-PLUGIN
User-agent: *
Disallow: /error/
Disallow: /stats/
Disallow: /cgi-bin/
Disallow: /images/
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content
Try to remove the last two lines…
Perhaps thew were added by some plugin. But, for example, the uploaded media and the theme data is stored in /wp-content, and any link to them will get declared as broken.
On the other side, the /wp-includes directory contains lots of files, some of which are directly included in your pages (.js, .xml, etc.).
Try to do that and tell me your results!
Hope it helps!
NeoEGM.
Hi,
could you change the title of the plugin to something like “Google XML Sitemaps for qTranslate”? I just downloaded the plugin because I thought it was the normal one but got fatal errors because it didn’t find the qTranslate functions.
Thanks,
Theo
Hi Theo!
The name of the plugin should always have been “Google XML Sitemaps with qTranslate Support”. It was my mistake.
I’ve just fixed it and also added support for qTranslate not installed. (It now works without problems whether you have qTranslate installed or not).
Thanks for your comment!
NeoEGM.
Tnx ! Looks like a great plugin, going to install right now!
Thanks!
I’ve only published it in a qTranslate compatible version, based in the original “Google XML Sitemaps”…
Thanks for you comment!
NeoEGM.
Thank you so much, it seems to work straight off the bat. You are a legend!
Hi Nick!
Thanks for your comment!
Just as I told Fred, the original version of this plugin was not written by me… I’ve just made the adaptation to make it work correctly with qTranslate, based in the code published by Qian Qin…
Enjoy it
NeoEGM.
???????? ????????? Sitemap ? ??????? HTML ??? ???????????
Translation: add to generate a Sitemap in HTML format for visitors
Hi Foto,
You can use most of these plugins to perform the task you need:
http://wordpress.org/extend/plugins/search.php?q=sitemap+generator
Hope it helps!
NeoEGM.
Thanks a lot for your effort, this is a great time saver.
I’ve noticed some links are not referenced in the sitemap ; category, tag and author are only listed for the default language, I can’t see /alt_lang/category/, /alt_lang/tag/ and /alt_lang/author/ listed in the sitemap. Is this a problem on my end or a known limitation ?
Best,
Fred
Same for the archives as well, I forgot that one.
Hi Frederic!
I’ll check it out and reply you!
Thanks for your comment!
NeoEGM.
Hi NeoEGM,
Thanks for having a look at this, feel free to drop me a line should you need some more information.
Best,
Fred
It doesnt referenced Static page either…
Hi Nicolas!
Thanks for your comments…
I’ll take a look as soon as I have time and reply you…
Greetings!
NeoEGM.
Can’t install- says the header is missing. I have mac and am using safari. Thanks
Hi Sarita,
Could you please send me the exact message displayed and when does it get shown?
Also, I’d need a list of all your enabled plugins…
Thanks!
NeoEGM.
Other problem, if the name of your post is different for each language, it just show the name of the post of the default language.
If the post is called “test fr” for the french and “test en” for english” it show up like that in the sitemap.xml :
http://localhost/ze/blog/test-fr.html (CORRECT)
http://localhost/ze/en/blog/test-fr.html (WRONG)
The second should be : http://localhost/ze/en/blog/test-en.html
Same problem for me! Big problem, too.
Does anyone know about fixing it? Of do I change sitemap.xml manually?
Cheers,
Ian.
Very nice plug-in, thank you to share!
Hi tansuozhe!
Thanks for your comment!
I’m glad it’s useful for you!
Greetings!
NeoEGM.
hello my friends,
i have a problem look @this:
FIRST SITE:
# There was a problem writing your sitemap file. Make sure the file exists and is writable. Learn more
# There was a problem writing your zipped sitemap file. Make sure the file exists and is writable. Learn more
“but sitemap.xml and xitemap.xml.gz is on 777″ in the directory
DEBUG SITE:
Errors, Warnings, Notices
Warning: fopen(/www/htdocs/w00c2b7c/sitemap.xml) [function.fopen]: failed to open stream: Is a directory in /www/htdocs/w00c2b7c/wp-content/plugins/google-xml-sitemaps-with-qtranslate-support/sitemap-core.php on line 1698
Warning: gzopen(/www/htdocs/w00c2b7c/sitemap.xml.gz) [function.gzopen]: failed to open stream: Is a directory in /www/htdocs/w00c2b7c/wp-content/plugins/google-xml-sitemaps-with-qtranslate-support/sitemap-core.php on line 1711
MySQL Queries
Please edit wp-db.inc.php in wp-includes and set SAVEQUERIES to true if you want to see the queries.
greetings!
Hi Mario!
Sorry for the delay, I was on vacation…
I’ve just checked your site and it seems to have sitemap.xml and sitemap.xml.gz correctly created…
According to the info you sent me you had directories instead of files at those paths….
Greetings!
NeoEGM.
Hello,
Congratulations for your work done on the plugin.
but I have a problem and I do not understand why.
This situation:
1) I created a site in 4 languages with qtranslate
2) I created the site-map, but is incomplete. There are only 4 links:
http://www.mysite.com/
http://www.mysite.com/it/
http://www.mysite.com/de/
http://www.mysite.com/ru/
Why in the sitemap there isn’t other pages?
Thanks and good job
PS: excuse my English
Hi Seventh!
I’ve been quite busy these days…
I’ll check it as soon as I can and reply to you!
Greetings!
I have solved the memory problem removing some code from other plugins. Now the memory usage dropped to 23MB, enough to run on a shared host
Excellent, and now it works?
Yes runs smoothly! I’m also thinking about tweaking the cod to allow sitemap splits on maps larger than 50,000 URLS.
I hate having to dirty my hands into the original code (this means once there’s an update you’ll have to merge tweaks again), but I think basically you can keep the old version, there aren’t going to be such revolutionary improvements in next versions
Surely!
That’s a problem!
Anyway, you can always suggest the plugin original author to include them in his release (it’s more probable him to do it if you give him the exact code and place). I’ve done it with the qTranslate thing, but he never answered me.
Greetings!
Nice Tool, thanks i have now support 2 Langugaes and love Google Sitemaps.
Thanks for your comment!
Greetings.
Hi there,
can I use this plugin with WordPress 3.0?
Thanks for a quick reply,
Claudia
Yes, it works properly.
I’m using it with WordPress 3.0.
Greetings.
Hey,
I’m using it with WordPress 2.8 and works really good. Thanks!!
Thank you for your comment!
Hello NeoEGM,
Can you say to me if in the current version of Google XML SiteMap-Gen is there your feature?
If they don`t have it yet, maybe it will be nice to update it to the newest version, what do you think?
So, if they don`t have it and you want help to implement it, feel free to ask my help.
Best Regards,
Matheus
Hi Matheus,
I’ve been quite busy…
I’ve not updated the Google XML Sitemap plugin to the latest version yet. Anyway, I’ve not found any problem with the latest one I’ve patched.
I’ll do it when I have a break!
Thanks for your comment!
hi.
i installed this plugin BUT i get an error :
“The last run didn’t finish! Maybe you can raise the memory or time limit for PHP scripts. Learn more”
i increased memory limit to 128 but the error didn’tchanged…
i am usin wp 3.0.1
when i click on debug function i got a massage that tells me :
“Errors, Warnings, Notices
MySQL Queries
Please edit wp-db.inc.php in wp-includes and set SAVEQUERIES to true if you want to see the queries”
BUT I DONT HAVE WP-DB.INC.PHP file in my folders !!
please help me!
How many posts do you have?
Have you solved it?
900 posrs…
no …
ican’t solve
Are you using qTranslate?
Otherwise you could try the the plugin version which doesn’t have qTranslate support.
Then tell me what happened!
Greetings.
no i am using Google XML Sitemaps plugin.
Then I think the one which can help you the best is the original author, since I’ve only made some modifications for the plugin to work with qTranslate…
It would be quite helpful if you then told me how you fixed it!
Thanks!
Hello thanks for this great plugin, will it be possible to make it work together with this other plugin?
http://wordpress.org/extend/plugins/qtranslate-slug-with-widget/
I’ll check it and tell you…
Greetings!
Is there any update on that? I tried a few things, but nothing worked so far.
Please let us know if there is any progress on that
i’ve submit more than 50,000 url but google sitemap only can handle 50,000 url. According google sitemap guideline i must create separated sitemap 1.xml, sitemap 2.xml, how to fix it ? btw,this is awesome plugin no doubt…. thx
Hi!
You should send this to the original author since I’ve only added the qTranslate support…
Greetings!
Very nice plugin for WordPress!
Hello. I would like to ask about one problem with Google XML Sitemaps for qTranslate. Recently I relocated my website to wordpress and created the sitemap through this plugin. Before relocation I made all technical works (for preparation) at the subdomain. After relocation and activation of the plugin it works well, it creates sitemap and so on.
But when I go to debug function it sais there: Notice: Undefined property: stdClass::$post_content in ….http://mysubdomain.mydomain.com…….public_html/wp-content/plugins/google-xml-sitemaps-v3-for-qtranslate/sitemap-core.php on line 1932
But no error notification in my administrative panel of wordpress.
Maybe you know what I need to do to solve it or this is just because plugin installed automatically in a subdomain path and this is not a problem? Maybe I need just ignore this notice in debug function section?
Thank you in advance for all helpful advices!
Thanks for the plugin! I´ve finally found it.
Thats what i was looking for.
Kind regards!!