回答編集履歴

5

追記

2017/10/12 14:57

投稿

dit.
dit.

スコア3235

test CHANGED
@@ -144,6 +144,8 @@
144
144
 
145
145
  if ( $the_query->have_posts() ):
146
146
 
147
+ $x ='';
148
+
147
149
  ?>
148
150
 
149
151
  <ul>

4

追記

2017/10/12 14:56

投稿

dit.
dit.

スコア3235

test CHANGED
@@ -122,4 +122,62 @@
122
122
 
123
123
 
124
124
 
125
+
126
+
127
+ 再度追記
128
+
129
+ ページの計算をややこしく考えすぎました。
130
+
131
+ ```html
132
+
133
+ <?php
134
+
135
+ $args = array(
136
+
125
- これでもやりたいことと違うのであれば「質問者さんのやりたいこと」と私が読み取った内容が違うということでこれ以上はお手上げです。
137
+ 'post_type' => 'post',
138
+
139
+ 'posts_per_page' => 20,
140
+
141
+ );
142
+
143
+ $the_query = new WP_Query( $args );
144
+
145
+ if ( $the_query->have_posts() ):
146
+
147
+ ?>
148
+
149
+ <ul>
150
+
151
+ <?php
152
+
153
+ while ( $the_query->have_posts() ):
154
+
155
+ $the_query->the_post();
156
+
157
+ $x++;
158
+
159
+ $pageno = $x;
160
+
161
+ $pageno = $pageno/2;
162
+
163
+ $pageno = ceil($pageno);
164
+
165
+ ?>
166
+
167
+ <?php if($pageno==1): ?>
168
+
169
+ <li><a href="<?php echo home_url('/'); ?>" ><?php the_title(); ?></a></li>
170
+
171
+ <?php else : ?>
172
+
173
+ <li><a href="<?php echo home_url('/'); ?>page/<?php echo $pageno; ?>" ><?php the_title(); ?></a></li>
174
+
175
+ <?php endif; ?>
176
+
177
+ <?php endwhile; ?>
178
+
179
+ </ul>
180
+
181
+ <?php endif; wp_reset_query(); ?>
182
+
183
+ ```

3

補足

2017/10/12 14:03

投稿

dit.
dit.

スコア3235

test CHANGED
@@ -1,4 +1,6 @@
1
1
  追記・修正依頼に書くには長すぎたので回答へ書きましたがこの回答では何も解決していないことを先にお伝えしておきます。
2
+
3
+  →追記したもので解決したようです。
2
4
 
3
5
  昨日の質問の流れと今回の質問を見て、質問内容(と回答内容)がうまく伝わっていないように思ったのでまとめです。
4
6
 

2

追記

2017/10/12 13:05

投稿

dit.
dit.

スコア3235

test CHANGED
@@ -59,3 +59,65 @@
59
59
 
60
60
 
61
61
  条件分岐やなんやかんやうまく使えばできそうな気がしたんですが私には無理でした。
62
+
63
+
64
+
65
+ ---
66
+
67
+
68
+
69
+ 追記
70
+
71
+ とりあえず2件ずつの場合にはどうにかなるんではないでしょうか。
72
+
73
+ 書き方が完ぺきではないと思いますが
74
+
75
+ ```html
76
+
77
+ <?php
78
+
79
+ $args = array(
80
+
81
+ 'post_type' => 'post',
82
+
83
+ 'posts_per_page' => 10,
84
+
85
+ );
86
+
87
+ $the_query = new WP_Query( $args );
88
+
89
+ if ( $the_query->have_posts() ):
90
+
91
+ ?>
92
+
93
+ <ul>
94
+
95
+ <?php
96
+
97
+ while ( $the_query->have_posts() ):
98
+
99
+ $the_query->the_post();
100
+
101
+ $x++;
102
+
103
+ $pageno = $x-1;
104
+
105
+ $pageno = $pageno/2;
106
+
107
+ $pageno = floor($pageno)+1;
108
+
109
+ ?>
110
+
111
+ <li><a href="<?php echo home_url('/'); ?>page/<?php echo $pageno; ?>" ><?php the_title(); ?></a></li>
112
+
113
+ <?php endwhile; ?>
114
+
115
+ </ul>
116
+
117
+ <?php endif; wp_reset_query(); ?>
118
+
119
+ ```
120
+
121
+
122
+
123
+ これでもやりたいことと違うのであれば「質問者さんのやりたいこと」と私が読み取った内容が違うということでこれ以上はお手上げです。

1

分かりづらい表記の削除

2017/10/12 12:13

投稿

dit.
dit.

スコア3235

test CHANGED
@@ -44,12 +44,6 @@
44
44
 
45
45
 
46
46
 
47
- - 現在表示されているページが何ページ目だか知りたいわけではない
48
-
49
- - eggの投稿そのものにリンクしたいわけではない
50
-
51
-
52
-
53
47
  そのリンクをどこに表示したいのか、最終的に何がしたいのかが解りづらく、
54
48
 
55
49
  質問を編集するうちにeggの事が消え、