How do I find Which WordPress File to Edit

How many times have you asked yourself; “How do I figure out which file to edit in my WordPress blog”, to edit specific content of your WordPress website? I bet if you are a WordPress user, you have had issues with this before. I have many times. Here are a couple ways of finding what file has what content:

  • Make a complete local backup copy of your WordPress site on your desktop. Then you can use Notepad++’s file search feature to find out which file contains a specific string of text. Notepad++ can search using regular expressions too, so it can find almost anything. It may require a little patience to search for specified content if your WordPress site is on the larger side. So to do this, you will need an FTP client such as Filezilla and Notepad++, both are free to download and a quick Google search will find them for you.
  • There is also a PHP snippet you can use to tell you all files that were included in making up the content of the current WordPress page. To use this second method, copy and paste the following code into your current WordPress theme’s header.php file. If you are aware of the page you are seeking content in is using a different header file than the standard header.php, then edit that header file instead, otherwise, use wp-content/themes/your-theme/header.php and it should work. Find the opening body tag in the header file and copy and paste the following right after that body tag:

<?php
$included_files = get_included_files();

foreach ($included_files as $filename) {
    echo “$filename\n”;
}
?>

…after pasting the above code in your header file, upload the file with Filezilla allowing it to overwrite the original and go to and refresh the page in question and you should notice some text at the top of the page that wasn’t there before. That is the long list of files that make up the current WordPress page. User your browser’s “view source” feature to see one file per line or change the line break in the code to a br tag to see it listed neatly in the browser. I use the text line break because sometimes you may not be able to see the list in the browser, but you can always when viewing the HTML source code.

  • If it is a CSS file you are looking for, I user Firefox and its “inspect element” feature to look at the CSS and it will tell you what file is producing what line of CSS.

Summary

There you go, three different methods for finding where content originates in WordPress. Goodluck with your WordPress website.

Leave a Reply

Your email address will not be published. Required fields are marked *