Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress赢得';t显示自定义php文件,_Php_Wordpress_Url - Fatal编程技术网

Wordpress赢得';t显示自定义php文件,

Wordpress赢得';t显示自定义php文件,,php,wordpress,url,Php,Wordpress,Url,我的网站是wordpress。 我有一个文件api.php,它与index.html 但当我执行mysite.com/api.php时,它会重定向到wordpress页面,显示找不到任何页面 有没有办法通过url访问自定义php文件(例如api.php)呢?将您的文件放在wordpress目录的根目录下,wp配置文件就存在于该目录下。清除缓存并尝试通过url访问您的文件。将您的文件(api.php)放在wordpress目录的根目录下,wp-config.php文件就存在于此 Create fo

我的网站是wordpress。 我有一个文件
api.php
,它与
index.html
但当我执行
mysite.com/api.php
时,它会重定向到wordpress页面,显示找不到任何页面


有没有办法通过url访问自定义php文件(例如
api.php
)呢?

将您的文件放在wordpress目录的根目录下,wp配置文件就存在于该目录下。清除缓存并尝试通过url访问您的文件。

将您的文件(api.php)放在wordpress目录的根目录下,wp-config.php文件就存在于此

Create folder at your website root directory
like:
wp-admin
wp-content
wp-yourfolder/yourfile.php,
than in yourfile.php include

include('wp-config.php');
and do what you want like

$wpdb->get_results( "SELECT post_date, ID  FROM $wpdb->posts  WHERE post_status = 'publish' ");

清除缓存并尝试通过url访问您的文件。

不建议使用直接访问PHP文件。最好改用AJAX()或REST(),Wordpress中有特殊的URL重写规则,您可以通过
mysite.com/anyContentUrl
通过
index.html
访问您的站点。但是如果你想访问一个自定义文件,你必须精确到完整的URL,例如你的主题
mysite.com/wp-content/themes/yourTheme/file.php
。如果您不想显示此路径,请将其放置在站点根目录中的另一个文件夹中,例如(仍然使用其完整URL访问)请检查这一点,这与您的问题类似。它甚至不允许我访问子文件夹。(wp yourfolder)@user3603023您是否有保护某些文件夹访问的插件?或者更一般的安全插件?请参阅以下toturial:
Create folder at your website root directory
like:
wp-admin
wp-content
wp-yourfolder/yourfile.php,
than in yourfile.php include

include('wp-config.php');
and do what you want like

$wpdb->get_results( "SELECT post_date, ID  FROM $wpdb->posts  WHERE post_status = 'publish' ");