質問編集履歴
1
コード全体の記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -68,14 +68,69 @@
|
|
68
68
|
|
69
69
|
archive-news.php
|
70
70
|
```
|
71
|
+
<div class="main__wrapper">
|
72
|
+
<main class="news__contents">
|
71
|
-
|
73
|
+
<?php
|
74
|
+
$args = array(
|
75
|
+
'post_type' => 'news',
|
76
|
+
// 'posts_per_page' => get_option('posts_per_page'),
|
77
|
+
'posts_per_page' => 10,
|
78
|
+
); ?>
|
79
|
+
<?php $my_posts = get_posts( $args ); ?>
|
80
|
+
<ul class="news-items">
|
81
|
+
<?php
|
82
|
+
global $post;
|
83
|
+
if($posts): foreach($my_posts as $post): setup_postdata($post);
|
84
|
+
$post_id = $post->ID;
|
85
|
+
$link = get_post_meta($post_id,'link',true);
|
72
86
|
?>
|
87
|
+
<?php if($link) : ?>
|
88
|
+
<li class="news-list">
|
89
|
+
<a class="news-list__link" href="<?php echo $link; ?>">
|
90
|
+
<div class="news-list__set">
|
91
|
+
<time class="news-list__time" datetime="2019-02-01"><?php the_time(__('Y年n月j日')) ?></time>
|
92
|
+
|
93
|
+
<?php
|
94
|
+
if ($terms = get_the_terms($post->ID, 'cat_news')) {
|
95
|
+
foreach ( $terms as $term ) {
|
96
|
+
$term_slug = $term -> slug;
|
97
|
+
echo ('<div class="news-list__label ') ;
|
98
|
+
echo esc_html($term_slug) ;
|
99
|
+
echo ('">') ;
|
100
|
+
echo esc_html($term->name) ;
|
101
|
+
echo ('</div>') ;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
?>
|
73
105
|
</div>
|
74
106
|
<p class="news-list__txt">
|
75
107
|
<?php the_title(); ?>
|
76
108
|
</p>
|
77
109
|
</a>
|
78
110
|
</li>
|
111
|
+
<?php else : ?>
|
112
|
+
<li class="news-list">
|
113
|
+
<a class="news-list__link" href="<?php the_permalink() ?>">
|
114
|
+
<div class="news-list__set">
|
115
|
+
<time class="news-list__time" datetime="2019-02-01"><?php the_time(__('Y年n月j日')) ?></time>
|
116
|
+
<?php
|
117
|
+
if ($terms = get_the_terms($post->ID, 'cat_news')) {
|
118
|
+
foreach ( $terms as $term ) {
|
119
|
+
$term_slug = $term -> slug;
|
120
|
+
echo ('<div class="news-list__label ') ;
|
121
|
+
echo esc_html($term_slug) ;
|
122
|
+
echo ('">') ;
|
123
|
+
echo esc_html($term->name) ;
|
124
|
+
echo ('</div>') ;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
?>
|
128
|
+
</div>
|
129
|
+
<p class="news-list__txt">
|
130
|
+
<?php the_title(); ?>
|
131
|
+
</p>
|
132
|
+
</a>
|
133
|
+
</li>
|
79
134
|
<?php endif; ?>
|
80
135
|
<?php endforeach; endif;?>
|
81
136
|
|
@@ -86,24 +141,10 @@
|
|
86
141
|
pagination($additional_loop->max_num_pages);
|
87
142
|
}
|
88
143
|
?>
|
89
|
-
</main>
|
90
144
|
|
91
|
-
<aside class="sidebar__contents">
|
92
|
-
<div class="sidebar-item">
|
93
|
-
<p class="sidebar-item__ttl">新着記事</p>
|
94
145
|
|
95
|
-
<?php
|
96
|
-
$args = array(
|
97
|
-
'post_type' => 'news',
|
98
|
-
// 'posts_per_page' => 5,
|
99
|
-
'post_status' => 'publish',
|
100
146
|
|
101
|
-
); ?>
|
102
|
-
<?php $my_posts = get_posts( $args ); ?>
|
103
|
-
<ul class="sidebar-item__menu">
|
104
|
-
<?php
|
105
|
-
|
147
|
+
</main>
|
106
|
-
if($posts): foreach($my_posts as $post): setup_postdata($post);
|
107
148
|
```
|
108
149
|
|
109
150
|
|