-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-works.php
143 lines (127 loc) · 4.16 KB
/
single-works.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php get_header(); ?>
<div class="cover_area work_img"></div>
<!-- 画面全体のborder -->
<div class="bg_wrap">
<div class="container">
<!-- 背景の縦線 -->
<div class="bg-line"></div>
<!-- Works -->
<section id="works">
<h2 class="section_title" title="Works">Works</h2>
<?php if ( have_posts() ) : ?>
<?php
while ( have_posts() ) :
the_post();
?>
<article class="bd main">
<span class="draw draw_active"></span>
<time datetime="<?php the_time( 'Y-m-j' ); ?>"><?php the_time( 'Y.m.j' ); ?></time>
<h1><?php the_title(); ?></h1>
<div class="tags">
<?php
/**
* タグ(ターム)を表示 https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/wp_get_object_termsを参考
*/
$my_order = array(
'orderby' => 'name',
'order' => 'ASC',
);
$custom_post_tag_terms = wp_get_object_terms( $post->ID, 'skill', $my_order );
if ( ! empty( $custom_post_tag_terms ) ) {
if ( ! is_wp_error( $custom_post_tag_terms ) ) {
foreach ( $custom_post_tag_terms as $my_term ) {
$term_link = get_term_link( $my_term->slug, 'skill' );
echo '<a href="' . esc_html( $term_link ) . '">' . esc_html( $my_term->name ) . '</a>';
}
}
}
?>
</div>
<div class="main_content">
<?php
// "作業時間"のカスタムフィールドに値が入力されている場合のみ表示
$meta = get_post_meta( $post->ID, '作業時間', true );
if ( ! empty( $meta ) ) :
?>
<p class="right">作業時間:約<?php echo esc_html( $meta ); ?>時間</p>
<?php endif; ?>
<?php the_content(); ?>
</div>
</article>
<div class="prev_next">
<?php
/**
* 新しい投稿があればリンクを表示
*/
$next_post = get_next_post();
if ( ! empty( $next_post ) ) :
?>
<div class="leftcol"><?php next_post_link( '%link', '« 新しい投稿へ' ); ?></div>
<?php endif; ?>
<?php
/**
* 古い投稿があればリンクを表示
*/
$previous_post = get_previous_post();
if ( ! empty( $previous_post ) ) :
?>
<div class="rightcol"><?php previous_post_link( '%link', '古い投稿へ »' ); ?></div>
<?php endif; ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<article class="bd">
<span class="draw"></span>
<h1>投稿が見つかりません。</h1>
</article>
<?php endif; ?>
<?php
$args = array(
'post_type' => 'works',
'post_per_page' => 3,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article class="bd">
<span class="draw"></span>
<div class="post_img fade">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'thumbnail' ); ?></a>
</div>
<div class="right fade">
<time datetime="<?php the_time( 'Y-m-j' ); ?>"><?php the_time( 'Y.m.j' ); ?></time>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="tags fade">
<?php
/**
* タグ(ターム)を表示 https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/wp_get_object_termsを参考
*/
$my_order = array(
'orderby' => 'name',
'order' => 'ASC',
);
$custom_post_tag_terms = wp_get_object_terms( $post->ID, 'skill', $my_order );
if ( ! empty( $custom_post_tag_terms ) ) {
if ( ! is_wp_error( $custom_post_tag_terms ) ) {
foreach ( $custom_post_tag_terms as $my_term ) {
$term_link = get_term_link( $my_term->slug, 'skill' );
echo '<a href="' . esc_html( $term_link ) . '">' . esc_html( $my_term->name ) . '</a>';
}
}
}
?>
</div>
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
<div class="to_list">
<a class="to_list_btn" href="<?php echo esc_html( get_post_type_archive_link( 'works' ) ); ?>">実績一覧へ</a>
</div>
</section>
<?php get_footer(); ?>