質問編集履歴
1
回答
test
CHANGED
File without changes
|
test
CHANGED
@@ -105,3 +105,77 @@
|
|
105
105
|
|
106
106
|
|
107
107
|
ご教授いただけますと幸いです。
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
/解決方法/
|
112
|
+
|
113
|
+
function.php
|
114
|
+
|
115
|
+
```ここに言語を入力
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
function change_posts_per_page($query) {
|
120
|
+
|
121
|
+
if ( is_admin() || ! $query->is_main_query() ){
|
122
|
+
|
123
|
+
return;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
if ( $query->is_post_type_archive( 'blog' ) ) {
|
130
|
+
|
131
|
+
$query->set( 'posts_per_page', '3' );
|
132
|
+
|
133
|
+
return;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
add_action( 'pre_get_posts', 'change_posts_per_page' );
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
archive-blog.php
|
150
|
+
|
151
|
+
```ここに言語を入力
|
152
|
+
|
153
|
+
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
|
154
|
+
|
155
|
+
<article class="blog-item">
|
156
|
+
|
157
|
+
<p class="date">
|
158
|
+
|
159
|
+
<?php the_time('Y.m.d') ?>
|
160
|
+
|
161
|
+
</p>
|
162
|
+
|
163
|
+
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
|
164
|
+
|
165
|
+
<div>
|
166
|
+
|
167
|
+
<?php the_content(); ?>
|
168
|
+
|
169
|
+
</div>
|
170
|
+
|
171
|
+
</article>
|
172
|
+
|
173
|
+
<?php endwhile; ?>
|
174
|
+
|
175
|
+
<?php endif; ?>
|
176
|
+
|
177
|
+
<?php wp_pagenavi(); ?>
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
上記で無事解決しました!
|