Url To Query
Converts any kind of WordPress url (even custom rewrite rules) to related main query arguments.
by Giuseppe Mazzapica · github.com/gmazzap/url_to_query · website
★ 31stars
3kcomposer installs
6forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/gmazzap/url_to_query/archive/refs/heads/master.zipAlso on Packagist as gmazzap/url-to-query:
composer require gmazzap/url-to-queryFrom the readme
Url To Query
A WordPress plugin that allow resolving any kind of WordPress url (even from custom rewrite rules) to related main query arguments.
Requirements
- PHP 5.4+
- WordPress 3.9+
- Composer to install
Installation
The plugin is a Composer package and can be installed in plugin directory via:
What & Why
WP comes with a set of tools to convert custom urls into specific query variables:
is possible to change the permalink structure, and there is also an API to add completely custom rules, however, there is not a way to reverse the process: i.e. to know to which query arguments an arbitrary url is connected to.
The url resolving is done in core by parserequest method of WP class saved in the global $wp variable.
Using that method for the purpose explained above is hard/discouraged because:
it directly accesses to $SERVER, $POST and $GET variables, making hard to parse arbitrary urls not related with current HTTP request
it triggers some action hooks strictly related to current HTTP request parsing, that makes no sense to trigger for arbitrary urls
it accesses and modifies properties of global $wp variable that should not be changed after request is parsed or very
Read the full README on GitHub →
Releases
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.