How to delete the permalink (landing pages) of image in the media library in Wordpress?

风流意气都作罢 提交于 2019-12-12 17:25:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!