Created
November 27, 2012 10:28
-
-
Save wokamoto/4153514 to your computer and use it in GitHub Desktop.
[WordPress] サムネイルが無い場合に、メディアライブラリに登録されている特定の画像を出す奴
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function thumbnail_noimage($html, $post_id, $post_thumbnail_id, $size, $attr) { | |
if (!empty($html)) | |
return $html; | |
$post_thumbnail_id = 1234; // default thumbnail image id | |
$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); | |
return $html; | |
} | |
add_filter('post_thumbnail_html', 'thumbnail_noimage', 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment