简体   繁体   English

开发人员工具:监视wordpress /网站请求的php / html文件-搜索使用了哪个content.php

[英]Developer tools: Monitor a wordpress/website's requested php/html files - hunting which content.php is used

Hello I have been messing around with the website I am developing using wordpress as cms. 您好,我一直在搞乱使用Wordpress作为cms开发的网站。

and Just when I have finished everything, all the featured images from my home/index were gone. 当我完成所有操作后,我的住所/索引中的所有精选图像都消失了。

I did some experimenting and found out that Wordpress isn't using simply just content.php. 我做了一些实验,发现Wordpress并不仅仅是使用content.php。 I tested it by making obvious changes to it. 我通过对它进行明显的更改来对其进行测试。 I even tried renaming it (that would make all contents disappear) but nothing happened. 我什至尝试重命名它(使所有内容消失),但是什么也没发生。

Now I just want to know which files are included by thi line: 现在,我只想知道该行包含哪些文件:

<?php get_template_part( 'content', get_post_format() ); ?>

I've tried echoing the value of get_post_format(); 我试过回显get_post_format()的值; but it returns nothing. 但它什么也没返回。

is there a program to trace which php file it calls? 是否有一个程序来跟踪它调用哪个php文件? or is there a way to echo out the name of the php file it used? 还是有办法回显它使用的php文件的名称? or should I force wordpress to use the content.php I made changes? 还是应该强迫wordpress使用我进行过更改的content.php? if yes, how? 如果是,如何?

I would really appreciate any help. 我真的很感谢您的帮助。

This is kind of hacky, but might be able to get the job done. 这有点骇人听闻,但也许可以完成工作。

$filesBefore = get_included_files();

//after get_template_part( 'content', get_post_format() );

$files = array_diff($fileBefore, get_included_files());

echo '<pre>' . $files . '</pre>';

This should show you the difference between the files that had been included before the line you mentioned and then afterwards. 这应该显示您提到的行之前和之后的文件之间的差异。

<?php get_template_part( 'content', get_post_format() ); ?> <?php get_template_part( 'content', get_post_format() ); ?> calls content.php of your wordpress theme <?php get_template_part( 'content', get_post_format() ); ?>调用wordpress主题的content.php

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

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