dongzhan2029 2013-11-02 20:20
浏览 97
已采纳

有没有办法知道哪个PHP文件在Wordpress中生成了一个页面?

I am trying to make some changes to PHP files in Wordpress, but it is taking me a long time to find which PHP file to edit. Is there a way to know which PHP file generated a given page? Thanks!

More information: I understand the basic outline of Wordpress templates like header.php and single.php. However, I am having a hard time walking through the many theme-specific template files and finding which one serves what purpose. Specifically, I am looking at a generated webpage and attempting to edit it. And I am resorting to inserting

tags inside each of the probable template files until I find the right one. Is there a way, perhaps through dev-tool, to see which php file generated the DOM?

  • 写回答

3条回答 默认 最新

  • doudi7782 2013-11-03 00:04
    关注

    It is possible to get a list of all the included files through the get_included_files() function in PHP. Here is a PHP script to set in the footer.php file of your template :

    // echo '<!--'; // you can display this code or show it in an HTML comment
    $files = get_included_files();
    if ($display_only_theme_files === true) {
      $theme_folder = get_template_directory();
      foreach ($files as $key => $file) {
        if (strstr($file, $theme_folder) === false) {
          unset($files[$key]);
        }
      }
    }
    print_r($files);
    // echo '-->'; // you can display this code or show it in an HTML comment
    

    This script will show you all the included files related to your template. In other words, you will have the possibility to know which file template is used.

    Please, be sure to use this code only on your development mode and to delete it when you will be in production.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛