Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created November 27, 2012 10:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/4153514 to your computer and use it in GitHub Desktop.
Save wokamoto/4153514 to your computer and use it in GitHub Desktop.
[WordPress] サムネイルが無い場合に、メディアライブラリに登録されている特定の画像を出す奴
<?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