I'm exporting some posts from a WordPress site.
One of the attributes of a post instance derived from $posts = get_posts();
is guid .. $post->guid
which shows how to find the original post. Something like /?p=2152
When I go to a browser and paste in the guid URL it often redirects to the permalink URL which is the URL I'd like to reference back to.
How do you extract the permalink from a post instance derived from get_posts()
?
I'm exporting some posts from a WordPress site.
One of the attributes of a post instance derived from $posts = get_posts();
is guid .. $post->guid
which shows how to find the original post. Something like https://www.domain.au/?p=2152
When I go to a browser and paste in the guid URL it often redirects to the permalink URL which is the URL I'd like to reference back to.
How do you extract the permalink from a post instance derived from get_posts()
?
Thanks to Tom's suggestion of searching for permalink instead of pretty URLs I found the get_permalink function.
$permalink = get_permalink($post->ID);