How to find a specific line of code in WordPress

The best thing about WordPress is that you can easily edit your entire blog, change the layout, and customize your theme. But when it comes to a beginner blogger who doesn’t have the necessary knowledge about coding and hosting, the browser can display errors with some indication about the file lines.

This is what many people can’t solve, if you’re a newbie, you need to know how to find a specific line of code in WordPress to solve the problem.

The majority of the error messages with line indications that appear in browsers can be caused by theme function errors and poor server configurations. In some cases, you will get a similar error when you have wrong permissions or outdated theme files in WordPress.

The WordPress error messages with line codes are not as many other issues. In that case, you get a line that has the problem, and even, you get exactly the wrong syntax and words.

Please make sure that you have a full backup of your blog, to avoid any future mistakes, that you can make. Even, if you’re sure at 100% about the solutions, in some cases the problem can happen.

First, you need an editor software to be able to open the WordPress files that are in PHP. So, what you need now is to download the best and most popular PHP editor called  Notepad ++. You can also download one called “Sublime Text” for Mac, both work well.

It works on Windows and Mac, and it’s open-source and it can display any file with lines, colors, and a great interface that even a child can understand. You will see the number of lines in your file. So, you will be able to find any link showing in the WordPress error messages.

how to find a specific line of code in wordpress

You can also find and download other editors like TextWrangler, which is built especially for Mac. But, I strongly recommend Notepad, it’s useful for all OS and easy to understand and edit files. It’s a small zip file that doesn’t need any settings to start working.

How to find a specific line of code with Notepad?

After downloading Notepad, login to your hosting account and locate the file where you have an error. Then, download it to your local machine.

Related:  How to delete unused database tables in WordPress from uninstalled plugins

Then, right-click and click “Edit with Notepad++” and you get the file opened as below:

edit file code

As you can see, you can find the exact line of code in your WordPress file, and edit it. If you have a long file, just click on ”Ctrl+F” to search the exact line in the box. Thus, you are able to change codes or to delete them if they’re not necessary.

After completing the editing, save the file, at the top right corner, and replace your old file by uploading the new updated file to your WordPress folders.

If you can’t download the file from your hosting control panel, you can edit the file directly in its location by using an FTP client like Filezilla.

All you have to do is to log in with your FTP details and locate the file with problems. Next, right-click and “Edit File”, the file will be downloaded automatically to your local machine, edit it and click ”save”. You will notice a message that validates the changes by replacing the old file with the new one.

Through these two methods, you can edit any file in WordPress, and find codes to solve errors. The real step here is to read carefully the error message and find the exact code to avoid mistakes, with other files that work properly.

Avatar for Fathi Arfaoui
About Fathi Arfaoui

Fathi Arfaoui is a Physicist, Blogger and the founder of Trustiko.com. He shares Business, WordPress and Blogging tips to build a better blog and succeed online.

Disclosure: The recommendations on this page are my own based on my tests and analysis. We may earn a small commission from web hosts and other partners if you use my referral link to make a purchase. That’s what helps us to maintain the site and add fresh content, Thanks for your support.

Leave a Comment