dsb12300 2015-06-17 10:41
浏览 45

如何将PHP脚本添加到wordpress

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?

  • 写回答

1条回答 默认 最新

  • donglu0494 2015-06-17 10:45
    关注

    You can add this class into function.php file in WordPress.

    function.php location wp-content/themes/(activeTheme)/function.php

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建