Find all URLs for a post

时间:2021-12-28 作者:Phil Lord

我想从wordpressblog中提取所有帖子的链接。这似乎很简单,可以使用wp-cli来完成。例如:

wp post list --field=url --post_type=post --posts_per_page=-1 --post_status=publish
然而,我的站点更复杂,因为我在某个时间点更改了站点的永久链接结构。现在,wordpress似乎在这里做了明智的事情;之前存在的所有永久链接都被保留,并且正在使用301重定向进行重定向。这太棒了,就我的一生而言,我找不到哪里可以看到这些重定向。我尝试搜索wordpress editinginterface,但在那里找不到任何内容,也找不到代码引用。

有没有办法获取wordpress重定向到其他地方的所有URL?或者重定向到给定帖子的所有URL?

1 个回复
最合适的回答,由SO网友:Phil Lord 整理而成

我已经知道发生了什么事。Wordpress不存储以前创建的永久链接。它所做的就是通过查看帖子名称猜出你想要的链接。

考虑:

https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/

wget https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/
--2021-12-31 00:09:51--  https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/
Resolving wordpress.com (wordpress.com)... 192.0.78.17, 192.0.78.9
Connecting to wordpress.com (wordpress.com)|192.0.78.17|:443... connected.
HTTP request sent, awaiting response... 200 OK

所有这些都是有意义的,但现在:

wget https://wordpress.com/blog/new-year-new-success-with-bloganuary/
--2021-12-31 00:10:19--  https://wordpress.com/blog/new-year-new-success-with-bloganuary/
Resolving wordpress.com (wordpress.com)... 192.0.78.17, 192.0.78.9
Connecting to wordpress.com (wordpress.com)|192.0.78.17|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/ [following]
或:

wget https://wordpress.com/blog/new-year-new-success/
--2021-12-31 00:10:54--  https://wordpress.com/blog/new-year-new-success/
Resolving wordpress.com (wordpress.com)... 192.0.78.17, 192.0.78.9
Connecting to wordpress.com (wordpress.com)|192.0.78.17|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/ [following]
--2021-12-31 00:10:55--  https://wordpress.com/blog/2021/12/16/new-year-new-success-with-bloganuary/
Reusing existing connection to wordpress.com:443.
它甚至只适用于一封信,尽管这会分解为不同的(旧的)帖子

wget https://wordpress.com/blog/n
--2021-12-31 00:11:41--  https://wordpress.com/blog/n
Resolving wordpress.com (wordpress.com)... 192.0.78.9, 192.0.78.17
Connecting to wordpress.com (wordpress.com)|192.0.78.9|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.com/blog/2013/12/03/nablopomo-2013/ [following]
--2021-12-31 00:11:41--  https://wordpress.com/blog/2013/12/03/nablopomo-2013/
Reusing existing connection to wordpress.com:443.
这就是为什么我在数据库中找不到它们。他们不在那里。解决方案是简单地将旧URL从归档中拉出。为我保存它们的组织。

相关推荐

Only plain permalinks working

我对一个站点(多站点结构的一部分)有问题。突然,除了主页,所有静态页面都显示了最后一篇帖子的列表。单桩工作正常。如果我将永久链接从;职位名称;“到”;“普通”;一切正常。这里是htaccess文件。RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?