カスタム投稿新着一覧を出力するコード
-
新着一覧を出力するコードをfunctionに入れたのですが、
menu というカスタム投稿の場合、これをどう書き換えたらいいかわかりません。
よろしくお願いいたします。//新着一覧を出力するショートコード function getCatItems($atts, $content = null){ extract(shortcode_atts(array( "num" => '5', "cat" => '' ), $atts)); global $post; $oldpost = $post; $myposts = get_posts('numberposts='.$num.'&order=DESC&orderby=post_date&category='.$cat); $retHtml = '<ul>'; $i = 0; foreach($myposts as $post): setup_postdata($post); $i = $i + 1; //$retHtml.='<li class="li'.$i.'"><h4><a href="'.get_permalink().'">'.get_the_post_thumbnail($id).'<span class="entry-date">'.get_the_date('m月d日').'</span> <span class="entry-title">'.mb_substr($post->post_title, 0, 20).'</span></a></h4></li>'; $retHtml.='<li class="li'.$i.'"><a href="'.get_permalink().'"><span class="entry-date">> '.get_the_date('Y.m.d').'</span> <span class="entry-title">'; if (strlen($post->post_title) > 60) { $retHtml.=mb_substr($post->post_title, 0, 60).'...'; }else{ $retHtml.= get_the_title(); } $retHtml.='</span></a></li>'; endforeach; $retHtml.='</ul>'; $post = $oldpost; return $retHtml; } add_shortcode("list","getCatItems");
3件の返信を表示中 - 1 - 3件目 (全3件中)
3件の返信を表示中 - 1 - 3件目 (全3件中)
- トピック「カスタム投稿新着一覧を出力するコード」には新たに返信することはできません。