質問編集履歴
3
コードの整理
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
WPに詳しい方ではないので不足な情報等あるかと思いますがどなたかご教示いただけましたら幸いです。
|
8
8
|
よろしくお願い致します。
|
9
9
|
|
10
|
+
```ここに言語を入力
|
10
11
|
<!--archive.php-->
|
11
12
|
<ul>
|
12
13
|
<?php
|
@@ -66,4 +67,5 @@
|
|
66
67
|
echo "</div>\n";
|
67
68
|
}
|
68
69
|
}
|
69
|
-
?>
|
70
|
+
?>
|
71
|
+
```
|
2
コードの整理
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,63 +7,63 @@
|
|
7
7
|
WPに詳しい方ではないので不足な情報等あるかと思いますがどなたかご教示いただけましたら幸いです。
|
8
8
|
よろしくお願い致します。
|
9
9
|
|
10
|
-
|
10
|
+
<!--archive.php-->
|
11
11
|
<ul>
|
12
12
|
<?php
|
13
13
|
$list_cnt = 15; //表示させたい件数
|
14
|
-
$sticky = get_option('sticky_posts'); //先頭固定の記事
|
14
|
+
$sticky = get_option( 'sticky_posts' ); //先頭固定の記事
|
15
|
-
if ( !empty($sticky
|
15
|
+
if ( !empty( $sticky ) )$list_cnt -= count( $sticky );
|
16
|
-
$the_query = new WP_Query(array(
|
16
|
+
$the_query = new WP_Query( array(
|
17
|
-
'post_type' => array('products'),
|
17
|
+
'post_type' => array( 'products' ),
|
18
|
-
'post__not_in' => array( $data[0]->ID ),
|
18
|
+
'post__not_in' => array( $data[ 0 ]->ID ),
|
19
19
|
'posts_per_page' => $list_cnt,
|
20
|
-
'paged' => get_query_var('paged')
|
20
|
+
'paged' => get_query_var( 'paged' )
|
21
|
-
));
|
21
|
+
) );
|
22
|
-
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
|
23
22
|
?>
|
23
|
+
<?php while ( $the_query->have_posts() ) : $the_query->the_post();?>
|
24
24
|
<li>contents</li>
|
25
25
|
<?php
|
26
26
|
endwhile;
|
27
|
-
wp_reset_postdata();
|
27
|
+
wp_reset_postdata();
|
28
|
+
?>
|
28
29
|
</ul>
|
29
30
|
|
30
31
|
<?php
|
31
|
-
|
32
|
+
if ( function_exists( "pagination" ) ) {
|
32
|
-
|
33
|
+
pagination( $additional_loop-- > max_num_pages );
|
33
|
-
|
34
|
+
}
|
34
35
|
?>
|
35
|
-
|
36
|
+
<!--function.php-->
|
36
|
-
|
37
|
+
<?php
|
37
|
-
{
|
38
|
-
$showitems = ($range * 5)+1;//表示するページ数(5ページを表示)
|
39
38
|
|
40
|
-
|
39
|
+
function pagination( $pages = '', $range = 2 ) {
|
41
|
-
|
40
|
+
$showitems = ( $range * 5 ) + 1; //表示するページ数(5ページを表示)
|
42
41
|
|
43
|
-
|
42
|
+
global $paged; //現在のページ値
|
44
|
-
{
|
45
|
-
global $wp_query;
|
46
|
-
|
43
|
+
if ( empty( $paged ) )$paged = 1; //デフォルトのページ
|
47
|
-
if(!$pages)//全ページ数が空の場合は、1とする
|
48
|
-
{
|
49
|
-
$pages = 1;
|
50
|
-
}
|
51
|
-
}
|
52
44
|
|
45
|
+
if ( $pages == '' ) {
|
46
|
+
global $wp_query;
|
47
|
+
$pages = $wp_query->max_num_pages; //全ページ数を取得
|
53
|
-
|
48
|
+
if ( !$pages ) //全ページ数が空の場合は、1とする
|
54
|
-
|
49
|
+
{
|
55
|
-
echo "<div class=\"pagenation\">\n";
|
56
|
-
|
50
|
+
$pages = 1;
|
51
|
+
}
|
52
|
+
}
|
57
53
|
|
58
|
-
|
54
|
+
if ( 1 != $pages ) //全ページが1でない場合はページネーションを表示する
|
59
|
-
|
55
|
+
{
|
56
|
+
echo "<div class=\"pagenation\">\n";
|
57
|
+
echo "<ul>\n";
|
58
|
+
|
59
|
+
for ( $i = 1; $i <= $pages; $i++ ) {
|
60
|
-
|
60
|
+
if ( 1 != $pages && ( !( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) {
|
61
|
-
{
|
62
|
-
|
61
|
+
//三項演算子での条件分岐
|
63
|
-
|
62
|
+
echo( $paged == $i ) ? "<li class=\"active\">" . $i . "</li>\n": "<li><a href='" . get_pagenum_link( $i ) . "'>" . $i . "</a></li>\n";
|
64
|
-
|
63
|
+
}
|
65
|
-
|
64
|
+
}
|
66
65
|
echo "</ul>\n";
|
67
66
|
echo "</div>\n";
|
68
|
-
|
67
|
+
}
|
69
|
-
}
|
68
|
+
}
|
69
|
+
?>
|
1
一部テキスト修正しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Seamless Sticky Custom Post Typesを使用して一覧ページ
|
1
|
+
Seamless Sticky Custom Post Typesを使用して一覧ページの先頭に固定表示させてページネーションを正常に動作させたい
|
body
CHANGED
File without changes
|