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

Konrad Karpieszuk kkarpieszuk at gmail.com
Fri Mar 21 12:02:14 UTC 2014


hi

Imagine that you have some text (let it be a post content) with urls. I
want to take all urls (it is something what i know how to do), check if the
links are local (again, something easy) and if they are, check what exactly
should be queried from wordpress, what should be in wp_query.

Does wordpress has some easy function/methid to do this?

Like get_wp_query_by_url('http://example.com/archive/some-category-name')
which will return wp_query for 'some-category-name' archive page.

Another question, maybe more suitable for me: does wordpress has some easy
function/method which will return $_GET params which should be set when we
want to open this url?

Something like get_query_params_by_url('http://example.com/some-post');
which will return:

array(
'p' => 12
)

(params which normally will be added as $_GET to url if permalinks are set
to default)

Thank you in advance. Now everything what i do is to get url, slice it to
get its path and compare it with wp_rewrite. But because wordpress somehow
knows what it must display if somebody type some url in address bar i am
little affraid that there is some easier method than manual checking if url
matches to wp_rewrite rules

--
(en) regards / (pl) pozdrawiam
Konrad Karpieszuk
http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla
klientów z Polski


More information about the wp-hackers mailing list