現在、サイト制作において、noteの記事(最新6件)の埋め込みをしております。
https://dubdesign.net/web/wordpress/nolugin-notecard/
上記のサイトをコピペしましたが、「サムネイル」が表示されません。
「サムネイル」を表示させるためには、どこを編集したら良いでしょうか?
ご教示いただきたいです。
下記にコードを貼り付けています。
php
1<?php 2include_once(ABSPATH . WPINC . '/feed.php'); 3$rss_arr = array('https://note.com/〇〇'); 4$rss = fetch_feed($rss_arr);if (!is_wp_error( $rss ) ) : 5//全部表示する場合は -1 6$maxitems = $rss->get_item_quantity(6); 7$rss->set_cache_duration(1800); 8$rss_items = $rss->get_items(0, $maxitems); endif;?> 9<div class="notecardtype cf"> 10<!--// 取得できた RSS フィードが0件の時は「No items.」と表示します。--> 11<?php if ($maxitems == 0) echo '<li>No items.</li>'; 12else 13foreach ( $rss_items as $item ) : ?> 14<article class="notecardtype__article"> 15<a class="notecardtype__link" href='<?php echo $item->get_permalink(); ?>' target="_blank"> 16<p class="notecardtype__img"> 17<?php if(has_post_thumbnail()): ?> 18<!--//サムネイルがなければ規定の画像を表示します--> 19<?php 20 $hash = substr($item->get_link(), strrpos($item->get_link(), '/') + 1); 21 $api_data = file_get_contents('https://note.mu/api/v1/' . 'notes/' . $hash); 22 $eyecatch = json_decode($api_data, true)['data']['eyecatch']; 23?> 24<?php 25 $first_img = ''; 26 if (preg_match('/<img.+?src=[\'"]([^\'"]+?)[\'"].*?>/msi',$item->get_content(), $matches )) { $first_img = $matches[1]; } 27?> 28<?php 29 if (!empty($eyecatch)){ 30 echo '<img src="'.$eyecatch.'" alt="'.$item->get_title().' eyecatch" width="640" height="auto">'; 31 }; 32?> 33<?php 34 if (!empty($first_img)){ 35 echo '<p class="thumb"><img src="'.esc_attr($first_img).'" alt="'.$item->get_title().' first_img" /></p>'; 36}; ?> 37<?php 38 if(empty($eyecatch) && empty($first_img)){ 39 echo '<img src="../default.jpg" >'; 40 }; 41?> 42<?php endif; ?> 43</p> 44<div class="notecardtype__article-info"> 45<time class="notepubdate entry-time dfont" itemprop="datePublished" datetime="<?php echo $item->get_date('Y.m.d');// 日付 ?>"><?php echo $item->get_date('Y.m.d');// 日付 ?></time> 46<p class="notecardtitle"><?php echo $item->get_title(); ?></p> 47</div> 48</a> 49 <a class="dfont notecat-name catid60"><img src="https://dubdesign.net/wp-content/uploads/2020/11/note_logo.png" alt="note"></a> 50<p class="notedescription"><?php echo mb_substr(strip_tags($item->get_description()), 0, 80);// 抜粋記事の文字数を指定 ?>...</p> 51</article> 52<?php endforeach; ?> 53</div>