ループ内でタグが取得できない
-
初心者ですが、ご質問させてください!
ショートコードにて
下記の内容で出力したのですが
get_the_tags()
だけが Arrayと
表示されて取得できませんご教授をお願いいたします。
function show_Cat_Posts_func($atts) { global $post; $output = ""; extract(shortcode_atts(array( 'cat' => 1,// デフォルトカテゴリーID = 1 'show' => 6, // デフォルト表示件数 = 3 ), $atts)); $cat = rtrim($cat, ","); // get_postsで指定カテゴリーの記事を指定件数取得 $args = array( 'cat' => $cat, 'posts_per_page' => $show ); $my_posts = get_posts($args); // 上記条件の投稿があるなら$outputに出力、マークアップはお好みで if ($my_posts) { // カテゴリーを配列に $cat = explode(",", $cat); $catnames = ""; foreach ($cat as $catID) : // カテゴリー名取得ループ $catnames .= get_the_category_by_ID($catID).", "; endforeach; $catnames = rtrim($catnames, ", "); $output .= '<aside class="showcatposts">'."\n"; $output .= '<ul class="showcatposts-list clearfix">'."\n"; foreach ($my_posts as $post) : // ループスタート setup_postdata($post); // get_the_title() などのテンプレートタグを使えるようにする $output .= '<li id="post-'.get_the_ID().'" '.get_post_class().'>'.get_the_tags().'<span>'.get_post_time('Y.m.d').'<a href="'.get_permalink().'">'.get_the_post_thumbnail().'</a><br></span> <a href="'.get_permalink().'">'.get_the_title().'<p style="color:#568485;">'.get_the_excerpt().get_the_tags('id')."</p></a></li>\n"; endforeach; // ループ終わり $output .= "</ul>\n"; $output .= "</aside>\n"; } // クエリのリセット wp_reset_postdata(); return $output; } add_shortcode('showcatposts', 'show_Cat_Posts_func');
4件の返信を表示中 - 1 - 4件目 (全4件中)
4件の返信を表示中 - 1 - 4件目 (全4件中)
- トピック「ループ内でタグが取得できない」には新たに返信することはできません。