admin管理员组文章数量:1130349
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()?
- 1 the pretty URL is also known as the permalink, you'll get a lot more/better results trying to search with permalink rather than pretty URL. Also, GUIDs aren't always URLs, or the current URL of the post, don't trust them blindly – Tom J Nowell ♦ Commented Jan 2, 2019 at 1:23
- Thanks @TomJNowell. permalink searching was fruitful. – Keith John Hutchison Commented Jan 2, 2019 at 2:08
1 Answer
Reset to default 0Thanks to Tom's suggestion of searching for permalink instead of pretty URLs I found the get_permalink function.
$permalink = get_permalink($post->ID);
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()?
- 1 the pretty URL is also known as the permalink, you'll get a lot more/better results trying to search with permalink rather than pretty URL. Also, GUIDs aren't always URLs, or the current URL of the post, don't trust them blindly – Tom J Nowell ♦ Commented Jan 2, 2019 at 1:23
- Thanks @TomJNowell. permalink searching was fruitful. – Keith John Hutchison Commented Jan 2, 2019 at 2:08
1 Answer
Reset to default 0Thanks to Tom's suggestion of searching for permalink instead of pretty URLs I found the get_permalink function.
$permalink = get_permalink($post->ID);
本文标签: Extracting the permalink from a post instance
版权声明:本文标题:Extracting the permalink from a post instance 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749052768a2308877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论