Let’s say I have a permalink. Now I want to know how to CORRECTLY reverse engineer that permalink back into site ID, blog ID, type (e.g. ‘post’, ‘attachment’, etc.), and type ID. Basically, feed in a permalink and get back an array of useful information. I know get_permalink() generates a permalink, so what is the inverse function called?
You could get the URI using _SERVER and then split it down in to its componant parts using implode() – finally run some functions on the relevant array keys to get the info you want. Very long winded, probably not worth it, but possible for those who wish to persevere!
@duck__boy – “probably not worth it”. I wouldn’t be asking if it wasn’t worth it.
@esmi – I just knew someone would drop in and be completely unhelpful. Congratulations, you’re “that person”.
I know WP pretty well as well as being an expert PHP developer, so I wouldn’t be asking if I didn’t need such functionality. I am more than capable of hacking something together, but what I want to know is what the “CORRECT” way of doing what I want to do? There’s always the hacky way and then there is right way.
Since my post 35-ish minutes ago, I’ve scoured the WP codebase and have come across:
url_to_postid() – requires switch_to_blog() and restore_current_blog() calls, but I’m used to doing that extensively already.
get_blog_id_from_url() – which is rather misleading as to what it does.
I’ve got a few ideas but this is hardly ideal.
Edit: BTW, I already have the permalinks I’m looking to reverse engineer. So, the $_SERVER recommendation is equally useless.
Edit #2: Unless you are an expert PHP and WP web developer who has used WP multisite _extensively_, then please don’t reply.