I'm trying to get the permalink of a post without using Wordpress functions and am trying to find the best way to go about it. Basically whats happening is that I have a multi site install of Wordpress as well as some other domains that are forwarding to the main Wordpress site. A specific url from those other domains is querying the database to pull some information about certain posts to display and give a link to. The problems that I'm having are twofold:
Originally these URLs were going to be within the multisite subdomains, so I was using get_the_permalink(). They then requested these outside URLs. Because the url isn't the same, when I include wp-blog-header.php, it just forwards to the main URL of the site, therefore, I can't use Wordpress functions and am stuck using SQL queries to get the info straight from the database.
I was doing my best to duplicate how the permalinks are created and just doing post title with spaces replaced and all lower case, but on posts that have the same title as other posts, the permalink has a "-2" or some other number in it, this causes an incorrect permalink.
I either need to be able to use Wordpress functions or find a way to properly get the permalink without using those functions, any ideas on which way to go would be greatly appreciated. Thanks for the help!