カテゴリに属する投稿一覧をコピペで作ってみます。nopwop-post-listスニペットの使い方です。
カテゴリID指定
以下は、WordPressのカテゴリのIDを指定する場合です。
scriptタグのcategoryid属性に4を指定しています。
リストに表示する数はcount属性で指定します。
<script listtype='category-posts' categoryid="4" count="2" src='https://cdn.jsdelivr.net/gh/nopwop/nopwop@0.1/dist/nopwop-post-list.min.js'></script>
実際の表示はこちらです↓
カテゴリ名指定
以下は、カテゴリ名を指定した場合です。
scriptタグのname属性に探したいカテゴリのカテゴリ名(ここでは、WordPressのTips)を指定します。日本語も問題なく表示されます。
<script listtype='category-posts' name='WordPressのTips' src='https://cdn.jsdelivr.net/gh/nopwop/nopwop@0.1/dist/nopwop-post-list.min.js'></script>
実際の表示はこちらです↓カテゴリID=4のslugを指定したので、結果は上記と同じです。
Slug指定
以下は、slugを指定した場合です。
scriptタグのslug属性に探したいカテゴリのslug(ここでは、wordpress-tips)を指定します。
<script listtype='category-posts' slug='"wordpress-tips' count=2 src='https://cdn.jsdelivr.net/gh/nopwop/nopwop@0.1/dist/nopwop-post-list.min.js'></script>
実際の表示はこちらです↓
Thumbnailがない場合のデフォルトのイメージ
記事にアイキャッチ画像を設定していない場合に表示されるデフォルトのサムネールはURL指定で置き換えることができます。defaultimg属性でしていします。
<script listtype='category-posts' slug='wordpress-tips' count=2 defaultimg='/wp-content/uploads/2021/06/pexels-pixabay-355952-458x318.jpg' src='https://cdn.jsdelivr.net/gh/nopwop/nopwop@0.1/dist/nopwop-post-list.min.js'></script>
実際の表示はこちらです↓