kxkkxk
フォーラムへの返信
3件の返信を表示中 - 1 - 3件目 (全3件中)
-
フォーラム: 使い方全般
返信が含まれるトピック: wordpressのランダム表示の優先度指定mizube様
ご返信ありがとうございます。本当にありがとうございます。現在試しているのですが、どういう記述になるのかいまいちわからず…
<?php $query1 = array('posts_per_page' => 2); // クエリ1 $query2 = array('posts_per_page' => 5); // クエリ2 query_posts( $query1 ); if ( have_posts() ) { $count = 0; while ( have_posts() ) { the_post(); // loop 1 $count++; } $query2['posts_per_page'] -= $count; } query_posts($query2); if ( have_posts() ) { while ( have_posts() ) { the_post(); // loop 2 } } wp_reset_query(); ?> <?php if(have_posts()):while(have_posts()):the_post(); ?> <a href='<?php the_permalink() ?>'><?php the_title(); ?></a> <?php endwhile; ?> <?php endif; ?>となるのでしょうか?
フォーラム: 使い方全般
返信が含まれるトピック: wordpressのランダム表示の優先度指定フォーラム: 使い方全般
返信が含まれるトピック: wordpressのランダム表示の優先度指定mizube 様
アドバイスありがとうございます。
ご指摘いただいてアドバイスで試行錯誤中なのですが上手く進めていません。
ソース内でクエリポストを途中で変える方法が理解できていません。have_posts() で記事がなかった場合の条件分岐で進めて行くとこのような感じになるのでしょうか?
<?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; query_posts('category_name=pu & posts_per_page=2 & paged=' . $paged); ?> <?php if(have_posts()):while(have_posts()):the_post(); ?> <a href='<?php the_permalink() ?>'><?php the_title(); ?></a> <?php endwhile; else: ?> <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; query_posts('category_name=カテゴリ2 & posts_per_page=5 &orderby=rand & paged=' . $paged); ?> <a href='<?php the_permalink() ?>'><?php the_title(); ?></a> <?php endif; ?>
3件の返信を表示中 - 1 - 3件目 (全3件中)