我有一个代码从API获取数据并将数据添加为Wordpress中的帖子。它假设每小时运行一次。
我不明白我将这个脚本放在wordpress中的哪个位置?
这是脚本,它是一个带有每小时触发器的php类。
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 );
}
}
}
可在此处找到完整代码:http://webbgaraget.se/2014/05/28/importera-nyheter-fran-mynewsdesk-till-wordpress-del-1/
我想在哪里放置此代码?
答案 0 :(得分:1)
您可以将此类添加到WordPress中的function.php文件中。
function.php location wp-content / themes /(activeTheme)/function.php