سؤال

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