Hey everybody.
Is there by any chance a function that could return the post ID having only the permalink to that post?
Thanks
Hey everybody.
Is there by any chance a function that could return the post ID having only the permalink to that post?
Thanks
Well, if you're NOT using pretty permalinks, then I believe the permalink actually contains the post ID. In which case you could probably use standard regex to isolate and store the ID in a variable.
Nevermind, I found the function. It's called url_to_postid() in rewrite.php
Thanks!
Interesting function. Nice find. Some random Googling brings up stuff (mostly old stuff) that indicates the function might be kind of touchy. Let us know how it works. :)
Works fine. It's used by the wordpress core when permalinks are enabled, so everything's okay :)
This topic has been closed to new replies.