0

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:

  1. 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.

  2. 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!

0

The simplest thing to do would be use non–pretty permalinks.

It is often overlooked, but you can just form a link like example.com?p=123 and WordPress will understand it and automagically redirect to pretty permalink too (if enabled, which is typically is).

Only need site URL and ID for the post, no PHP calls, no complex stitching it together from data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.