Everytime I get a visitor from Google images to my Wordpress blog it takes them to an image page where it shows the image and nothing else. This is useless because it leaves the visitor with an image and no context or content to show.

Is there a way to redirect the google search results to the WordPress post that contains that image? I know it's possible because I've seen it in other blogs.

有帮助吗?

解决方案

within your theme create an file called image.php and simply add the following code:

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

this will redirect the attachment page to the post parent, which is usually the page the image is featured on.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top