Monday, August 15, 2011

Custom time or interval for Cron to Wordpress

If you want to specify another interval to run a cron job in Wordpress beside the 3 built in you can do so. The custom code for specify another cron interval is:

add_filter( 'cron_schedules', 'my_corn_schedules');
function my_corn_schedules(){
return array(
'per_minute' => array(
'interval' => 60,
'display' => 'Every Mintue'
)
);
}

Interval is how many seconds in between. And display is an value for naming the interval or custom cron interval. Remember that when you are creating a cron job with the built in cron function in Wordpress, the cron job triggers by a user when the user is visiting your website.

Wednesday, February 23, 2011

The Dagon Design Sitemap Generator plug-in for wordpress and WP_Error

I've had some trouble with the Dagon Design Sitemap Generator for Wordpress, version 3.15. When I installed it for my Wordpress 3.0 installation, I got an error on the page.

The error message i got was: Catchable fatal error: Object of class WP_Error could not be converted to string in .. \wp-content\plugins\sitemap-generator\sitemap-generator.php on line 513

It seems like I'm not the only one who has this problem when I googled for 'sitemap-generator.php on line 513'. Neither has the founder of the plug-in updated it lately so there seems like there is no update for this problem.

However I've found an solution or rather work around to this problem that seems to work.

What to do is to modify the PHP code with just a few lines.
The original code was on line 513:
return DDSG_CAT_HEADER . ' < a href="' . get_category_link($post_data[$p]['id']) . '" title="' . strip_tags($post_data[$p]['title']) . '">' . $post_data[$p]['title'] . '< /a>';

Now the modifications that needs to be done are:

if(is_string($p))
return DDSG_CAT_HEADER . ' < a href="' . get_category_link($post_data[$p]['id']) . '" title="' . strip_tags($post_data[$p]['title']) . '">' . $post_data[$p]['title'] . '< /a>';
else
return false;


The only thing you need to do with this is to remove the white-spaces after '<' in the code because Blogger will treat that as a link so I had to make an space in between.

The problem seems to be empty categories, but I'm not sure.