WordPressでの質問です。
下記のソースは新着記事の一覧と記事をランダムに2つ表示させる物です。
記事を2つだけランダムに表示させようとすると新着記事一覧も連動してランダムに同じものが表示されてしまいます。
連動しないように別々で動くようにしたいのですがどうしたらいいのでしょうか?
index.phpでの記述です。
テーマはtwentyseventeenで子テーマを作っています。
<!-- ランダム記事表示 --> <?php query_posts('showposts=2&orderby=rand');?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_post_thumbnail; ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?></a> <?php endwhile; endif; ?> <!-- ランダム記事表示 --> <?php if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'template-parts/post/content', get_post_format() ); endwhile; else : get_template_part( 'template-parts/post/content', 'none' ); endif; ?>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/10/15 16:31 編集
2018/10/15 16:32
退会済みユーザー
2018/10/15 16:34
退会済みユーザー
2018/10/15 16:35