admin管理员组文章数量:1317894
I'm working on remaking a big website with its upload folder already full of many gigabits of images. I just noticed a problem I never noticed with WordPress before: it seems to create attachment pages based on the name of the images, which means that it "steals" most of the page slugs I want to use.
For example, let's say I have an image named about.jpg
in my upload folder. The URL mysite/about
will be created and automatically redirect to that image. Now, if I want to create a regular page named About, the URL doesn't have the priority on the attachment and will be forced be called mysite/about-2
.
It's quite frustrating to not have clean URLs, and I haven't found much on the web about it, which is strange. It tried the filter mentioned here but it doesn't seem to do anything. Any help would be appreciated. Thank you :)
I'm working on remaking a big website with its upload folder already full of many gigabits of images. I just noticed a problem I never noticed with WordPress before: it seems to create attachment pages based on the name of the images, which means that it "steals" most of the page slugs I want to use.
For example, let's say I have an image named about.jpg
in my upload folder. The URL mysite/about
will be created and automatically redirect to that image. Now, if I want to create a regular page named About, the URL doesn't have the priority on the attachment and will be forced be called mysite/about-2
.
It's quite frustrating to not have clean URLs, and I haven't found much on the web about it, which is strange. It tried the filter mentioned here but it doesn't seem to do anything. Any help would be appreciated. Thank you :)
Share Improve this question asked Oct 24, 2020 at 9:54 morceaudeboismorceaudebois 713 bronze badges 2- The filter would probably only work if you set it up before importing the images. If your images are already imported then I guess you either want some behaviour to spot if an image already has a slug on page save and rename it out of the way, or just e.g. run some SQL to change all the slugs where post_type = 'attachment'? Is that something you could try, after you've taken a database backup? – Rup Commented Oct 25, 2020 at 13:16
- Thanks for you answer :) This is indeed what I ended up doing. I just changed the slugs that I needed in the database, and they became available. – morceaudebois Commented Oct 26, 2020 at 11:32
1 Answer
Reset to default 3I've found a workaround if someone has the same problem:
In the database, you can search for the attachment page that's causing problem, you'll find it in wp_posts
by searching for its post_name
(which is the slug you want). Then just rename that post_name (in about-img
for example). It isn't a fix but it will make the desired slug available for your page's URL.
本文标签: Attachment pages stealing page slugs
版权声明:本文标题:Attachment pages stealing page slugs 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742037220a2417364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论