taxonomyのアーカイブページに最新の記事を5件表示させたいと思っています。
そこで以下のphpファイルを作成し読み込ませたところ、最新の記事5件は表示できたものの、エラー文が表示されてしまいました。
【phpファイル】
<h4 class="menu_underh2">新着求人</h4> <div class="kanren <?php st_marugazou_class(); //サムネイルを丸くする ?>"> <?php global $post; $get_term = get_the_terms($post->ID, 'area'); $term = array_shift($get_term); $args = array( 'numberposts' => 5, //8件表示(デフォルトは5件) 'post_type' => 'job', //カスタム投稿タイプ名 'orderby' => 'date', //ランダム表示 ); ?> <?php $myPosts = get_posts($args); if($myPosts) : ?> <?php foreach($myPosts as $post) : setup_postdata($post); ?> <dl class="clearfix"> <dt><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></dt> <dd> <h5 class="kanren-t"> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h5> <?php if( !st_is_mobile() && trim( $GLOBALS['stdata202'] ) === '' )://モバイル以外の場合のみ表示 ?> <div class="smanone"> <?php the_excerpt(); //抜粋文 ?> </div> <?php endif; ?> </dd> </dl> <?php endforeach; ?> <?php else : ?> <p>関連記事はありませんでした</p> <?php endif; wp_reset_postdata(); ?> </div>
【エラー文】
Warning: array_shift() expects parameter 1 to be array, boolean given innewpost-custom-area.php on line 6
記事自体は表示されているので、変数などの箇所でおかしくなっていると思うのですが、どこの箇所がおかしいのか分からず困っております。
ご助力いただけますでしょうか?
回答1件
あなたの回答
tips
プレビュー