最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Added slug after URL permalink last slash returns different content

programmeradmin0浏览0评论

I'm a webdev but have zero wordpress experience, and I'm helping a friend.

So I have permalinks to posts in this format:

/

However for some reason there are also links in this format that return content:

/

And the latter format returns a page with the same title, a single image, but none of the text. I'm not sure how and why these latter URLs are being created nor how to remove them. I'd like those URLs to redirect to the actual post (eg / redirecting to /).

Any idea how I might do this?

Here is a live example:
/
/

I'm a webdev but have zero wordpress experience, and I'm helping a friend.

So I have permalinks to posts in this format:

https://example/some-slug/

However for some reason there are also links in this format that return content:

https://example/some-slug/alternative-categoryA-categoryB-blog-1/

And the latter format returns a page with the same title, a single image, but none of the text. I'm not sure how and why these latter URLs are being created nor how to remove them. I'd like those URLs to redirect to the actual post (eg https://example/some-slug/alternative-categoryA-categoryB-blog-1/ redirecting to https://example/some-slug/).

Any idea how I might do this?

Here is a live example:
https://lolawho/lola-loves-mike-parisellas-otherworldly-mixed-media-collages/
https://lolawho/lola-loves-mike-parisellas-otherworldly-mixed-media-collages/mike-parisella-lola-who-fashion-music-photography-blog-1/

Share Improve this question asked May 7, 2020 at 22:38 Rom GrkRom Grk 1112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Those links are called Attachment pages, and Wordpress creates one for each media attachment in a post. There are a few plugins to disable them. To redirect the user to the actual post, one can add the following line of code:

// in wp-content/themes/[your-child-theme]/image.php

<?php wp_redirect(get_permalink($post->post_parent)) ; ?>

Link: https://www.greengeeks.ca/tutorials/article/set-wordpress-to-disable-attachment-pages-for-media/

发布评论

评论列表(0)

  1. 暂无评论