[wp-hackers] get wp_query object when you have url to post

Nikola Nikolov nikolov.tmw at gmail.com
Fri Mar 21 14:24:56 UTC 2014


You can find the code in /wp-includes/class-wp.php WP::parse_request -
https://github.com/WordPress/WordPress/blob/3.8-branch/wp-includes/class-wp.php#L120


If you scroll down to line 199, you will see the foreach loop over the
rewrite rules.

Bad code written by other people is bad :)


On Fri, Mar 21, 2014 at 4:03 PM, Konrad Karpieszuk <kkarpieszuk at gmail.com>wrote:

> Actually WordPress does the same thing internally(well it's a bit more
> > complicated, but it's about the same) - it goes through all rewrite rules
> > until it finds a matching regex pattern.
> >
>
> could you show me where it happen? which part of code?
>
> i want to look on this and check how it is done and if it can inspire me
>
>
>
> >
> > What is the reason behind why you need this functionality?
> >
>
> Actually i don't need but i must ;) I work now on some legacy code, which
> doesn't work correctly and is quite messy. I see only that it iterates
> wp_rewrite rules and match links. I want to check if i can rewrite it in
> better way. I tried to patch it but it looks now that it already has too
> much patches which just fix one issue and do next one. Code has now about
> 500 lines and i feel that it is too much.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list