且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WordPress 页面模板中的 PHP 代码不执行

更新时间:2023-12-01 22:32:28

我刚刚发现了问题.逐项调试后,问题是WordPress不允许您运行file_get_contents,而必须像这样使用wp_remote_get:

I just found the problem. After debugging every bit item by item, the problem is that WordPress doesn't allow you to run file_get_contents, instead you have to use wp_remote_get like this:

GOOD: $json = wp_remote_get( $social['twitter'].$url );
BAD: $json = file_get_contents($social['twitter'].$url, false);

我只是浪费了一整天的时间,所以我希望它可以帮助其他人.

I just wasted a full day on this so I hope it helps someone else.