2017-08-30 83 views
0

我使用wordpress懶惰加載插件https://wordpress.org/plugins/lazy-load/。它適用於帖子&頁面,但自定義帖子類型不起作用,想知道如何將其應用於自定義帖子類型?感謝WP懶惰加載插件自定義帖子類型

add_filter('lazyload_images_placeholder_image', 'my_custom_lazyload_placeholder_image'); 
function my_custom_lazyload_placeholder_image($image) { 
return 'images/preloader.gif'; 
} 

這是我的嘗試,但是不知道該怎麼做:

add_filter('lazyload_images_placeholder_image', 'my_custom_lazyload_placeholder_image'); 
function my_custom_lazyload_placeholder_image($image_src, $image) { 
    $image_src = 'images/preloader.gif'; 
    return $image_src; 
    $post_types = $post_types = array('post', 'video_library', 'example1_posts', 'example2_posts', 'example3_posts', 'example4_posts', 'example5_posts', 'example6_posts'); 
    $image->set('post_type', $post_types); 
    return $image; 
} 

回答

0

沒關係我已經把我的CPT圖像

$attachment = wp_get_attachment(get_post_thumbnail_id($post->ID)); $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(650,350), false, '');

我改爲下方現在它工作。看起來像這個插件沒有設置爲支持上述獲取發佈縮略圖圖像的方法。

the_post_thumbnail('full', array('class' => 'img-responsive'));

相關問題