3

How to avoid errors due to not having the specific functions of wordpress inside the projet when making a Wordpress Theme on Visual Studio Code ?

Is there a plugin to download ?

Errors vscode wordpress

4 Answers4

10

Wordpress stubs are included in In VSCode.

You just need to activate it.

If you follow these steps your errors will disapear.

  1. Hit the gear icon.(bottom left)
  2. Select settings.
  3. Search for stubs.
  4. Scroll all the way down an click on 'Add item'.
  5. Hit the dropdown menu.
  6. Press w(on your keyboard) and scroll to worpress and select it.
  7. Hit ok.

Now all the error should disapear.

If not, try to restart VSCode.

Dharman
  • 30,962
  • 25
  • 85
  • 135
JPenther
  • 136
  • 1
  • 6
2

You can try using WordPress Stubs https://github.com/php-stubs/wordpress-stubs. The easy way is download this file https://raw.githubusercontent.com/php-stubs/wordpress-stubs/master/wordpress-stubs.php (Wordpress v5.8.1) and paste in your theme.

Lopongoaca
  • 21
  • 2
1

Open VS Code in the root of the WordPress installation.

You get this error because you are referring to functions that are not in your open files in your editor.

  • ah ok... but I don't wan't to open everything, that be too much to display. Isn't there a plugin for vscode that would solve this ? – Benoit Adam Apr 09 '21 at 23:30
1

If you follow these steps your errors will disappear.

Click on gear icon > Select settings > Search for stubs > Scroll down an click on 'Add item' > select WordPress > Hit ok

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129