如何防止wordpress通过图像链接?

时间:2014-04-09 12:03:36

标签: php wordpress

默认情况下,您在编辑器中输入的wordpress链接图像。如何关闭此操作。

找到了这个解决方案,但它没有用。

add_filter( 'the_content', 'attachment_image_link_remove_filter' );
function attachment_image_link_remove_filter( $content ) {
$content =
preg_replace(
array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
'{ wp-image-[0-9]*» /></a>}'),
array('<img','» />'),
$content
);
return $content;
}

2 个答案:

答案 0 :(得分:0)

Insert Media窗口中,您可以选择要将图片链接到的内容。只需选择

No link

答案 1 :(得分:0)

将此代码添加到主题的function.php文件中。

function wpb_imagelink_setup() {
    $image_set = get_option( 'image_default_link_type' );

    if ($image_set !== 'none') {
        update_option('image_default_link_type', 'none');
    }
}
add_action('admin_init', 'wpb_imagelink_setup', 10);

由于