Note: everything done here has been made on a server running Ubuntu.
Then I have installed the Sitemaps generator plugin for wordpress.
After the configuration of the plugin I have encountered several issues.
The first one was that the plugin was not able to generate the sitemaps file for my blog (6000 posts) and was returning the following error :
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /home/xxx/public_html/ntfr/wp-includes/plugin.php on line 302
So I first tried to upgrade my Apache configuration by updating the variable memory_limit to 64M in /etc/php5/apache2/php.ini and then restart Apache but I was still facing the same problem.
Then I have tried to add the following code to the wp-config.php file but the problem was still there:
define('WP_MEMORY_LIMIT', '64M');The next step was to take a look at the plugin code and I have made a change to the sitemap.php file in the LoadPlugin function by upgrading memory_limit to 64M. The code changed is below:
1
2
3 function LoadPlugin() {
4
5 $mem = abs(intval(@ini_get('memory_limit')));
6 if($mem && $mem < 32) {
7 @ini_set('memory_limit', '64M');
8 }
9
10 $time = abs(intval(@ini_get("max_execution_time")));
11 if($time != 0 && $time < 120) {
12 @set_time_limit(120);
13 }
14
15 if(!class_exists("GoogleSitemapGenerator")) {
16
17 $path = trailingslashit(dirname(__FILE__));
18
19 if(!file_exists( $path . 'sitemap-core.php')) return false;
20 require_once($path. 'sitemap-core.php');
21 }
22
23 GoogleSitemapGenerator::Enable();
24 return true;
25 }
26
Thanks to all the changes described above I was able to generate a Google Sitemaps for my wordpress blog but the content of the file was not ok for me due to the fact that last modification of the posts was not correct. The migration from drupal to wordpress is not filling the following fields of the wp_posts table :
- post_modified
- post_date_gmt
- post_modified_gmt
UPDATE wp_posts SET post_modified = post_date;
UPDATE wp_posts SET post_date_gmt = convert_tz(post_date, 'Europe/Paris', 'GMT');
UPDATE wp_posts SET post_modified_gmt = convert_tz(post_modified, 'Europe/Paris', 'GMT');
Note: before using convert_tz you will have to setup mysql timezones by typing the following command:
mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root mysql -p
