0

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.

4

1 回答 1

1

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.

于 2013-03-29T20:29:40.430 回答