回答編集履歴
5
追記
answer
CHANGED
@@ -71,6 +71,7 @@
|
|
71
71
|
);
|
72
72
|
$the_query = new WP_Query( $args );
|
73
73
|
if ( $the_query->have_posts() ):
|
74
|
+
$x ='';
|
74
75
|
?>
|
75
76
|
<ul>
|
76
77
|
<?php
|
4
追記
answer
CHANGED
@@ -60,4 +60,33 @@
|
|
60
60
|
<?php endif; wp_reset_query(); ?>
|
61
61
|
```
|
62
62
|
|
63
|
+
|
64
|
+
再度追記
|
65
|
+
ページの計算をややこしく考えすぎました。
|
66
|
+
```html
|
67
|
+
<?php
|
68
|
+
$args = array(
|
63
|
-
|
69
|
+
'post_type' => 'post',
|
70
|
+
'posts_per_page' => 20,
|
71
|
+
);
|
72
|
+
$the_query = new WP_Query( $args );
|
73
|
+
if ( $the_query->have_posts() ):
|
74
|
+
?>
|
75
|
+
<ul>
|
76
|
+
<?php
|
77
|
+
while ( $the_query->have_posts() ):
|
78
|
+
$the_query->the_post();
|
79
|
+
$x++;
|
80
|
+
$pageno = $x;
|
81
|
+
$pageno = $pageno/2;
|
82
|
+
$pageno = ceil($pageno);
|
83
|
+
?>
|
84
|
+
<?php if($pageno==1): ?>
|
85
|
+
<li><a href="<?php echo home_url('/'); ?>" ><?php the_title(); ?></a></li>
|
86
|
+
<?php else : ?>
|
87
|
+
<li><a href="<?php echo home_url('/'); ?>page/<?php echo $pageno; ?>" ><?php the_title(); ?></a></li>
|
88
|
+
<?php endif; ?>
|
89
|
+
<?php endwhile; ?>
|
90
|
+
</ul>
|
91
|
+
<?php endif; wp_reset_query(); ?>
|
92
|
+
```
|
3
補足
answer
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
追記・修正依頼に書くには長すぎたので回答へ書きましたがこの回答では何も解決していないことを先にお伝えしておきます。
|
2
|
+
→追記したもので解決したようです。
|
2
3
|
昨日の質問の流れと今回の質問を見て、質問内容(と回答内容)がうまく伝わっていないように思ったのでまとめです。
|
3
4
|
勝手にまとめてしまいましたがこの解釈も間違っている可能性があります。
|
4
5
|
|
2
追記
answer
CHANGED
@@ -28,4 +28,35 @@
|
|
28
28
|
この時点で質問からeggの事が消えているので「何ページ目にeggがあるかの判断」は考慮されてません。
|
29
29
|
そのため http://投稿一覧のURL としか回答されておらず、質問者さんと回答者さんの間で認識のズレがおきているのではないかと思います。
|
30
30
|
|
31
|
-
条件分岐やなんやかんやうまく使えばできそうな気がしたんですが私には無理でした。
|
31
|
+
条件分岐やなんやかんやうまく使えばできそうな気がしたんですが私には無理でした。
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
追記
|
36
|
+
とりあえず2件ずつの場合にはどうにかなるんではないでしょうか。
|
37
|
+
書き方が完ぺきではないと思いますが
|
38
|
+
```html
|
39
|
+
<?php
|
40
|
+
$args = array(
|
41
|
+
'post_type' => 'post',
|
42
|
+
'posts_per_page' => 10,
|
43
|
+
);
|
44
|
+
$the_query = new WP_Query( $args );
|
45
|
+
if ( $the_query->have_posts() ):
|
46
|
+
?>
|
47
|
+
<ul>
|
48
|
+
<?php
|
49
|
+
while ( $the_query->have_posts() ):
|
50
|
+
$the_query->the_post();
|
51
|
+
$x++;
|
52
|
+
$pageno = $x-1;
|
53
|
+
$pageno = $pageno/2;
|
54
|
+
$pageno = floor($pageno)+1;
|
55
|
+
?>
|
56
|
+
<li><a href="<?php echo home_url('/'); ?>page/<?php echo $pageno; ?>" ><?php the_title(); ?></a></li>
|
57
|
+
<?php endwhile; ?>
|
58
|
+
</ul>
|
59
|
+
<?php endif; wp_reset_query(); ?>
|
60
|
+
```
|
61
|
+
|
62
|
+
これでもやりたいことと違うのであれば「質問者さんのやりたいこと」と私が読み取った内容が違うということでこれ以上はお手上げです。
|
1
分かりづらい表記の削除
answer
CHANGED
@@ -21,9 +21,6 @@
|
|
21
21
|
egg
|
22
22
|
```
|
23
23
|
|
24
|
-
- 現在表示されているページが何ページ目だか知りたいわけではない
|
25
|
-
- eggの投稿そのものにリンクしたいわけではない
|
26
|
-
|
27
24
|
そのリンクをどこに表示したいのか、最終的に何がしたいのかが解りづらく、
|
28
25
|
質問を編集するうちにeggの事が消え、
|
29
26
|
ウィジェットの最近の投稿を使っているという情報が入り、
|