質問編集履歴
1
メインループ箇所追加、mainSidebar.php呼び出し箇所追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,8 @@
|
|
7
7
|
‘posts_per_page’を最大投稿数と同じ20に設定しているときはちゃんとおすすめ記事が表示されます。しかし、‘posts_per_page’を最大投稿数以下に設定するとうまく表示されなくなるという問題が生じています。
|
8
8
|
|
9
9
|
###該当のソースコード
|
10
|
-
|
10
|
+
mainSidebar.php↓
|
11
|
+
```
|
11
12
|
<h2 class="mainSiderbarTitle">編集部おすすめ</h2>
|
12
13
|
<ul class="mainSiderbarUl">
|
13
14
|
<?php
|
@@ -50,12 +51,64 @@
|
|
50
51
|
<?php } endwhile; endif; ?>
|
51
52
|
</ul>
|
52
53
|
```
|
54
|
+
index.php メインループ↓
|
55
|
+
```
|
56
|
+
<!-- ********************************************************************
|
57
|
+
* 記事一覧
|
58
|
+
********************************************************************** -->
|
59
|
+
<!-- 11/23 -->
|
60
|
+
<?php if(is_paged()) : ?>
|
61
|
+
<ul>
|
53
62
|
|
63
|
+
<?php if (have_posts()) : ?>
|
64
|
+
<?php while (have_posts()) : the_post(); ?>
|
65
|
+
<li class="flex-fluid justify-start item-start link frontPostArea">
|
66
|
+
<a href="<?php the_permalink(); ?>">
|
67
|
+
<figure class="frontPostIconArea">
|
68
|
+
<?php
|
69
|
+
$img = get_field('postIcon');
|
70
|
+
$imgurl = wp_get_attachment_image_src($img, 'full');
|
71
|
+
?>
|
72
|
+
<?php the_post_thumbnail('medium'); ?>
|
73
|
+
</figure>
|
74
|
+
</a>
|
54
75
|
|
76
|
+
<div class="frontPostItem">
|
77
|
+
<a href="<?php the_permalink(); ?>">
|
78
|
+
<h3 class="frontPostTitle">
|
79
|
+
<?php the_title(); ?>
|
80
|
+
</h3>
|
81
|
+
</a>
|
82
|
+
|
83
|
+
<a href="<?php the_permalink(); ?>">
|
84
|
+
<div class="frontPostSummary">
|
85
|
+
<?php echo get_the_content(); ?>
|
86
|
+
</div>
|
87
|
+
</a>
|
88
|
+
|
89
|
+
<span class="frontPostTag">
|
90
|
+
<?php the_category(); ?>
|
91
|
+
</span>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
</li>
|
97
|
+
<?php endwhile; endif; ?>
|
98
|
+
</ul>
|
99
|
+
```
|
100
|
+
index.php mainSidebar.php呼び出し部分↓
|
101
|
+
```
|
102
|
+
<section class="col-sm-12 sp-lg-4" id="rightSidebarSection">
|
103
|
+
<?php get_template_part("./template/mainSidebar"); ?>
|
104
|
+
</section>
|
105
|
+
```
|
55
106
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
56
107
|
|
57
108
|
カスタムフィールド
|
58
109
|
->フィールド名:postRecommended
|
59
110
|
->フィールドタイプ:真/偽
|
60
111
|
|
61
|
-
管理画面の表示設定では最大投稿数を20に設定しています。
|
112
|
+
管理画面の表示設定では最大投稿数を20に設定しています。
|
113
|
+
|
114
|
+
index.phpでmainSidebar.phpをget_template_part()を使って呼び出しています。
|