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/
1 Answer
Reset to default 0Those 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/