Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to find out which php file has generated an html line of code in WordPress

Tags:

Using Chrome you can right click - Inspect element to see the html code behind that element:

Chrome inspect element example

I wonder how to find which php file has generated that html. Maybe there is some tool to put a breakpoint into the html so the php server will stop when trying to generate it again?

I'm using WordPress locally. I'm on Ubuntu 14.04LMS. I'm using Sublime Text 3 with XDebug.


UPDATE 1

A WordPress plugin able to put, in every file, something like the following would be a good solution (I think from my beginner's viewpoint):

echo '<!-- name_of_the_php_file.php -->'; 
like image 508
chelder Avatar asked Dec 12 '14 20:12

chelder


People also ask

How do you find out which PHP file is being used?

8 Answers. Show activity on this post. If you are using PHP as an Apache module then phpinfo() will tell you the php version used, and the php config files, NOT the php path. If you have 2 versions of the php executable then this will help you.

How can I check HTML code in PHP?

Simple way: Use file_get_contents() : $page = file_get_contents('http://stackoverflow.com/questions/ask');

How do I find the line of code in Wordpress?

Whether you're searching for a word, an entire phrase, or a piece of code, this plugin will be able to find it. All you have to do is navigate to Tools -> String Locator and start searching. The plugin will then scan through all the theme and plugin files you have installed, and it will find the search term.

How do I find the PHP file of a Wordpress page?

However, what I can suggest is installing WP Query Monitor plugin, and activate it. Then, visit the page that you will have your clients visit and check in the WP Query Monitor Debug Bar what “template” is used. That will indicate the PHP file (possibly within the plugin) that is used to display this content.


1 Answers

Use this plugin "what the file" to find out the php file. Then rest it is to find out a function or something else by CTRL + F in any editor.

I want to add one more plugin which is not exactly for this purpose but it is very popular among WordPress developers and it solves this problem very well. The plugin is Query Monitor.

like image 160
Rituparna sonowal Avatar answered Sep 19 '22 15:09

Rituparna sonowal