问题
I notice every image uploaded on wordpress website will have a separate page(a permalink to the image)
like this : https://www.knexusgroup.com/linkedin_logo_v1/
This is not good, how do I remove these page for every image? Every image have already CDN link.
I have got hold on images uploaded for blog post using Yost plugin
but these images are uploaded to pages & are not attached to the particular page. These images are not looking good on the search result.
Please help me how can I remove this from wordpress.
回答1:
Create a new file called image.php in your theme. Insert the code below in your image.php file,
<?php
global $post;
if ( $post && $post->post_parent ) {
wp_redirect( esc_url( get_permalink( $post->post_parent ) ), 301 );
exit;
} else {
wp_redirect( esc_url( home_url( '/' ) ), 301 );
exit;
}
来源:https://stackoverflow.com/questions/51511945/how-to-delete-the-permalink-landing-pages-of-image-in-the-media-library-in-wor