0

I am trying to substitute a calendar plugin for an old archive page of events. In archive.php I have the following code:

<?php get_header();
$cat = get_query_var('cat');
$yourcat = get_category ($cat);
global $gateway_parent_id;


if ( $yourcat->slug == 'events' ){
include 'page-forum.php';
}else{

?>

when I change line 8 to include 'http://www.mysite.com/events/'; I get the following errors:

Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /data/23/2/34/80/21912080/user/2412808/htdocs/wp-content/themes/ga/archive.php on line 8

Warning: include(http://www.mysite.com/events/) [function.include]: failed to open stream: no suitable wrapper could be found in /data/23/2/34/80/21912080/user/2412808/htdocs/wp-content/themes/ga/archive.php on line 8

Warning: include() [function.include]: Failed opening 'http://www.mysite.com/events/' for inclusion (include_path='.:/usr/services/vux/lib/php') in /data/23/2/34/80/21912080/user/2412080/htdocs/wp-content/themes/ga/archive.php on line 8

What am I doing wrong?

4

3 に答える 3

0

経由でファイルをインクルードしようとしています。サーバーの PHP 構成で無効になっている url。これを修正するallow_url_fopenには、php.ini で on を設定するか、代わりにファイル パスを使用することをお勧めします。

ファイルパスを介してファイルを含めるには、現在のphpファイルに関連するファイル名へのフルパスを使用し../、必要に応じてディレクトリを上に移動します。たとえば、/root/test/save.phpfromを含めたい場合は、 or だけ/root/dir/working/go.phpを使用します。include ('../../test/save.php');include('/root/test/save.php');

于 2013-06-25T21:46:11.417 に答える
0

include()とその関連は、ドキュメント ルートに相対的な Web パスではなく、ファイル システム パスを取ります。親ディレクトリを取得するには、次を使用します../

たとえば、含めたいファイルが archive.php とは異なるディレクトリにある場合、たとえばincludesのようにすると、次のようになります。

include('../includes/file.php');

/ で始まる場合、絶対システム ファイル パスが使用されます (つまり、スラッシュで始まるパスはすべて絶対パスになります)。例:

include('/home/user/public_html/project/include/config.php'); 

これがあなたの質問に答えることを願っています。

于 2013-06-25T22:04:50.590 に答える