Reputation: 5414
I have a code that fetch data from an API and add the data as posts in Wordpress. It's suppose to run hourly.
I don't understand where i place this script in wordpress?
This is the script, it's a php class with a hourly trigger.
class MND_News_Importer
{
private function _schedule_import()
{
// If the schedule isn't set
if ( !wp_next_scheduled( self::CRON_NAME ) )
{
// Use the built in function wp_schedule event to run the function every hour
wp_schedule_event( time(), 'hourly', self::CRON_NAME );
}
}
}
Full code can be found here: http://webbgaraget.se/2014/05/28/importera-nyheter-fran-mynewsdesk-till-wordpress-del-1/
Where am i suppose to place this code?
Upvotes: 0
Views: 57
Reputation: 2517
You can add this class into function.php file in WordPress.
function.php location wp-content/themes/(activeTheme)/function.php
Upvotes: 1