Internal (i.e. same domain) links not resolving PHPStorm / Wordpress
I am keen to link to other pages on my Wordpress site from my Wordpress site.
e.g. href="/mycat/mypage"
but if I do this PHPStorm says cannot resolve directory.
I can solve this by:
a) hard coding the links e.g. href="https://mysite.com/mycat/mypage"
or
b) Echoing out e.g. href="<?php echo site_url() . '/mycat/mypage'"
Both of these options are pretty unnecessary considering it resolves in the browser!
How can I fix this please? I assume it is something to do with roots.
Please sign in to leave a comment.
Hello,
Where is the "/mycat" directory located?
Usually directories are resolved from the same place as the current file.
What can you see when you press Ctrl+Space (or Cmd+Space) inside quotes of href? There should be path completion - where does it complete to?
Hi Vladimir,
Thanks for your help. /mycat isn't a directory is is part of the URL which Wordpress creates based on the taxonomy structure.
For example, if you have three posts under the category 'holiday-blogs' then you could find them at mysite.org/category/holiday-blogs.
A live example is here: https://benefacto.org/category/employee-volunteering-best-practice/
I pressed cmd-space inside of the href and it said 'cannot find declaration' to go to.
Any thoughts?
Cheers,
Linz
>Any thoughts?
Well ... those are just "nice" links that are handled during runtime only -- they do not point to actual real folder or file (hence they cannot be resolved).
If you do not like such noise -- just disable appropriate inspection (which looks rather useless in such circumstances)
OK, that's fine. Can you let me know how to do that please?
Cheers,
Linz
https://www.jetbrains.com/help/phpstorm/disabling-and-enabling-inspections.html
P.S. When doing right from the editor -- same as suppression -- just choose "disable" from that popup menu -- https://www.jetbrains.com/help/phpstorm/suppressing-inspections.html
Thanks.