If you have ever opened a project in VS Code and noticed that WordPress functions are highlighted in red, such as the_permalink() or the_title(), you are not alone. I have faced this myself and know how annoying it can be. In fact, your code works fine, the site does not crash, but the editor simply “does not understand” that these are WordPress functions. Let’s figure out how to make autocomplete work properly and get rid of the red underlines.
Why VS Code highlights functions in red
All WordPress functions that you use in a theme or plugin are not native PHP functions. They are defined inside the WordPress core. Intelephense, a VS Code extension, analyzes files in isolation, without knowing that your project is a WordPress site. That is why it reports Undefined function and highlights the functions in red.
It is important to understand that there is nothing wrong with the code itself — the site works correctly. The red underlines are purely an editor issue. Of course, you can simply ignore them, but for comfortable project work and proper autocomplete, it is better to configure the IDE correctly.
Solution: connecting WordPress stubs
For Intelephense to recognize all WP functions when WordPress functions are highlighted in red, you need WordPress stubs. These are special stub files that describe all WordPress core functions. They are not included on the website and do not affect it in any way — they are used exclusively by the IDE.
You can download them either via Composer or directly from GitHub. In practice, especially on servers with limited Composer support, using GitHub is more convenient.
Step-by-step guide: preparing stubs
Connect to the server via SSH or use Remote-SSH in VS Code.
Go to the WordPress root directory where wp-config.php is located. For example:
cd /home/w/your_hosting/your_domain/public_html/
Make sure you are in the correct place:
ls
You should see wp-config.php, wp-content, wp-includes, and other standard WordPress files.
Create a directory for stubs and download them from GitHub:
mkdir -p _ide
cd _ide
git clone https://github.com/php-stubs/wordpress-stubs.git
Check the contents of the folder:
ls wordpress-stubs
You should see .php files and other resources. These are the stubs — now Intelephense will be able to use them.
WordPress functions are highlighted in red: connecting stubs and configuring Intelephense
So, we have downloaded the WordPress stubs and made sure all files are in place. Now it is important to connect them correctly to Intelephense so that the editor stops highlighting WordPress functions in red. Let’s do this carefully, step by step.
Intelephense configuration
The first thing you need to do is open the VS Code Remote settings. To do this, press:
Ctrl + Shift + P
and type:
Preferences: Open Remote Settings (JSON)
A settings file like this will open:
~/.vscode-server/data/Machine/settings.json
This is where we will add the path to the stubs.
Correct path to the stubs
It is very important to specify the absolute path on the server. If you are not sure what the path to your _ide/wordpress-stubs folder is, run the following command:
pwd
You will get the full path, for example:
/home/w/webleg/wtemu.ru/_ide/wordpress-stubs
Now open settings.json and add the following:
"intelephense.environment.includePaths": [
"/home/w/webleg/wtemu.ru/_ide/wordpress-stubs"
]
Save the file (Ctrl + S) — this tells Intelephense where to look for WordPress functions.
Clearing the cache and checking
After adding the path to the stubs, you need to clear the Intelephense cache, otherwise the changes will not take effect.
In VS Code:
Ctrl + Shift + P
and select:
Intelephense: Clear Cache
After that, restart VS Code or the Remote SSH session.
Checking the result
Open any theme file, for example:
wp-content/themes/baskerville/content-gallery.php
You should see that functions such as:
the_permalink()
the_title()
have_posts()
are no longer highlighted in red, and autocomplete works as expected.
At this stage, Intelephense fully understands your WordPress project and no longer complains about core functions. This solution works on a server via SSH and does not require complex configuration or paid extensions.
Why this is important
WordPress works dynamically: themes and plugins load functions through the core. An IDE cannot “guess” that a file is executed in the context of WordPress. Intelephense is a static PHP analyzer, and it needs stubs to know which functions exist, what parameters they accept, and what values they return.
Now your editor fully cooperates with WordPress, and working on the project becomes comfortable.
Alternative for those using PHPStorm
If you want fully automatic recognition of WordPress functions without manually configuring stubs, you can use PHPStorm with the WordPress plugin. There, autocomplete and hints work out of the box. However, for VS Code, the stubs method remains the simplest and most reliable solution.
WordPress functions are highlighted in red: final tips and recommendations
We have already figured out why WordPress functions are highlighted in red, downloaded WordPress stubs, connected them to the editor, and cleared the cache. Now let’s summarize and look at a few additional points that will help make working with WordPress in VS Code as comfortable as possible.
Final check
After completing all the settings, open several theme or plugin files. The red underlines should disappear. WordPress core functions are recognized, autocomplete works, and hints show parameters and return value types.
If some functions are still highlighted in red, make sure the path to the stubs is specified correctly on the server and that the Intelephense cache has been cleared.
Additional tips
Organizing the stubs folder
I recommend keeping stubs separately, in the _ide folder at the root of the site. This is convenient, safe, and does not interfere with WordPress itself.
Working with SSH Remote
If you connect to the server via Remote-SSH, make sure that all Intelephense settings are applied specifically to the remote session, not to the local VS Code instance.
Scripts and hooks
Now that Intelephense knows all WordPress functions, working with hooks like add_action, add_filter, and objects such as WP_Query becomes much easier — autocomplete and hints save time and reduce the chance of errors.
Conclusion
To sum up, I want to emphasize:
Red underlines in VS Code are not a PHP error, but an editor issue caused by the fact that it does not see dynamic WordPress functions.
WordPress stubs solve this problem by providing the IDE with a static “skeleton” of functions.
Configuring settings.json and clearing the Intelephense cache completely eliminates the situation where WordPress functions are highlighted in red.
Now working with WordPress in VS Code is comfortable, safe, and productive.
I hope this article helped you understand the issue of WordPress functions being highlighted in red and made your development environment more convenient and stable.