Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.