简体   繁体   English

phpfile在wordpress标头中包含错误

[英]phpfile include error in wordpress header

i have this code in my home.php- 我的home.php-中有此代码

  <?php

   include('PHPLiveX.php');

 $ajax = new PHPLiveX();

    $ajax->Ajaxify(array("applyJob"));

    get_header();

    ?>

now i am moving this code to my header.php 现在我将这段代码移到我的header.php

include('PHPLiveX.php');

$ajax = new PHPLiveX();

$ajax->Ajaxify(array("applyJob"));

so that it will be available for all word-press file. 这样它就可用于所有word-press文件。 but its giving me blank page(no error). 但它给了我空白页(没有错误)。 i know that file is including because when i echo some content in the included file it shows in the page.the phplivex.php file contain a class which is used to ajaxify the theme. 我知道该文件包含其中,因为当我在包含的文件中回显某些内容时,该文件就会在页面中显示。phplivex.php文件包含一个用于使主题邻接的类。 any guess wats causing the blank page? 任何猜测会导致空白页吗?

You need to use complete real path of that file in-order to include it. 您需要按顺序使用该文件的完整真实路径才能将其包括在内。

include('FULLPATHOFDIRECTORY/PHPLiveX.php'); include('FULLPATHOFDIRECTORY / PHPLiveX.php');

FULLPATHOFDIRECTORY = has to be path to that directory which keep this file. FULLPATHOFDIRECTORY =必须是保存该文件的目录的路径。

I think that you should use include_once() or require_once() when you call this file in header.php. 我认为您在header.php中调用此文件时应使用include_once()require_once() Hope it helps. 希望能帮助到你。

U Go in your theme and in your active theme open function.php And Add this Code. U在您的主题和活动主题中打开“ function.php”,然后添加此代码。

function.php function.php

function IncludeFileFun(){
    include('PHPLiveX.php');
}

add_action( 'init', 'IncludeFileFun' );

Note : PHPLiveX.php File is include in your active theme folde. 注意 :PHPLiveX.php文件包含在活动主题文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM