phpStorm Doesn't Recognize WordPress if I set Content Root to the Theme Rather Than WordPress Root

I have a copy of WordPress on my local system. If I make my content root the base of the wordpress install (e.g. /wordpress/) it recognizes WordPress functions, etc.

But I want to work on a single theme and I don't need the entire WordPress install to work on that. When I change the content root from /wordpress/ to /wordpress/wp-content/themes/name-of-theme/ it stops recognizing WordPress functions, etc.

I have gone into Preferences-->Languages & Frameworks --> PHP --> WordPress and set the WordPress installation path to the base of the WordPress install (/wordpress/). I have also added as the WordPress base as an include path in Preferences-->Languages & Frameworks --> PHP, yet it still doesn't recognize the WordPress function calls.

What am I missing?

Thanks!

1
Avatar
Permanently deleted user
正式评论

Hello,

Does the behavior changes if you create Wordpress project from the scratch (like File > New Project > Wordpress Plugin and following the wizard further)? Would be great if you could try that out and let me know the results.

I have exactly this problem and working as Wordpress plugin makes no difference.

 

To reiterate; if the Theme or Plugin directory is within the Wordpress path there seems to be no way to get the Wordpress library to load.

0

Any news on this? I have the same problem as well. I only want to have the theme open as a project in the IDE but still want Phpstorm to recognize all Wordpress functions etc.

0

When you enable the WordPress support at Settings | PHP | Frameworks | WordPress, it asks you for a WordPress installation path.
This path will be added as a library to your project, so you don't need to add it manually.

if the Theme or Plugin directory is within the Wordpress path there seems to be no way to get the Wordpress library to load.

You are not supposed to put a plugin/theme path there. What you need to do is to open the plugin/theme as a project, and then add the WordPress installation in the way mentioned above.

0

I'm running into a similar issue when opening project.

/project/other resources
/project/wordpress

If I open the wordpress folder then everything works fine, the same issue occurs if you want to work with the /wp-content or themes folder.

It would be nice if I could use the Installation path in the settings, and then ONLY open my theme or plugin without requiring a complete site.

I have also noticed this with Laravel projects

/project/laravel requiring me to open Laravel instead of the protect.

0

请先登录再写评论。