質問編集履歴
5
コードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,9 +126,11 @@
|
|
126
126
|
|
127
127
|
<?php else:?>
|
128
128
|
|
129
|
+
<?php $img = get_field('img'); if( !empty($img) ): ?>
|
130
|
+
|
129
131
|
<div class="worksImg">
|
130
132
|
|
131
|
-
<
|
133
|
+
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>" />
|
132
134
|
|
133
135
|
</div>
|
134
136
|
|
4
コードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -71,3 +71,95 @@
|
|
71
71
|
|
72
72
|
|
73
73
|
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
追記のコード↓
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
<?php
|
86
|
+
|
87
|
+
// ループ条件を設定
|
88
|
+
|
89
|
+
$args = array(
|
90
|
+
|
91
|
+
'post_type' => array ('graphic','video','web'), /* 投稿タイプを指定 */
|
92
|
+
|
93
|
+
'paged' => get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1,
|
94
|
+
|
95
|
+
'posts_per_page' => 10, // 表示件数
|
96
|
+
|
97
|
+
'order' => 'date',
|
98
|
+
|
99
|
+
'order' => 'DESC',
|
100
|
+
|
101
|
+
);
|
102
|
+
|
103
|
+
?>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<div class="clearfix">
|
108
|
+
|
109
|
+
<?php query_posts( $args ); ?>
|
110
|
+
|
111
|
+
<?php if (have_posts()) : ?>
|
112
|
+
|
113
|
+
<?php while (have_posts()) : the_post(); ?>
|
114
|
+
|
115
|
+
<div class="works">
|
116
|
+
|
117
|
+
<?php $youtube = get_post_meta($post->ID, 'youtube', true); ?>
|
118
|
+
|
119
|
+
<?php if(!empty($youtube)):?>
|
120
|
+
|
121
|
+
<div class="VideoWrapper">
|
122
|
+
|
123
|
+
<?php echo $embed_code = wp_oembed_get( get_field('youtube') ); ?>
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<?php else:?>
|
128
|
+
|
129
|
+
<div class="worksImg">
|
130
|
+
|
131
|
+
<?php $img = get_field('img'); if( !empty($img) ): ?><img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>" />
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<?php endif; ?>
|
136
|
+
|
137
|
+
<div class="worksIco">
|
138
|
+
|
139
|
+
<h3><?php echo post_custom('crient'); ?></h3>
|
140
|
+
|
141
|
+
<p><?php echo post_custom('content'); ?></p>
|
142
|
+
|
143
|
+
</div>
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<?php endwhile; ?>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<?php else : ?>
|
152
|
+
|
153
|
+
<h1>記事がありません</h1>
|
154
|
+
|
155
|
+
<p>表示する記事はありませんでした。</p>
|
156
|
+
|
157
|
+
<?php endif; ?>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
</div><!-- /clearfix -->
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
```
|
3
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,3 +5,69 @@
|
|
5
5
|
内容としましては動画のフィールドに項目がある場合は動画を表示させて、動画が無い場合は画像を表示させたいです。
|
6
6
|
|
7
7
|
どんな方法があるでしょうか?
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```
|
12
|
+
|
13
|
+
<div class="clearfix">
|
14
|
+
|
15
|
+
<?php query_posts( $args ); ?>
|
16
|
+
|
17
|
+
<?php if (have_posts()) : ?>
|
18
|
+
|
19
|
+
<?php while (have_posts()) : the_post(); ?>
|
20
|
+
|
21
|
+
<div class="works">
|
22
|
+
|
23
|
+
<?php $youtube = get_post_meta($post->ID, 'youtube', true); ?>
|
24
|
+
|
25
|
+
<?php if(!empty($youtube)):?>
|
26
|
+
|
27
|
+
<div class="VideoWrapper">
|
28
|
+
|
29
|
+
<?php echo $embed_code = wp_oembed_get( get_field('youtube') ); ?>
|
30
|
+
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<?php else:?>
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
<div class="worksImg">
|
38
|
+
|
39
|
+
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>" />
|
40
|
+
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<?php endif; ?>
|
44
|
+
|
45
|
+
<div class="worksIco">
|
46
|
+
|
47
|
+
<h3><?php echo post_custom('crient'); ?></h3>
|
48
|
+
|
49
|
+
<p><?php echo post_custom('content'); ?></p>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<?php endwhile; ?>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<?php else : ?>
|
60
|
+
|
61
|
+
<h1>記事がありません</h1>
|
62
|
+
|
63
|
+
<p>表示する記事はありませんでした。</p>
|
64
|
+
|
65
|
+
<?php endif; ?>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
</div><!-- /clearfix -->
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
```
|
2
内容変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,104 +4,4 @@
|
|
4
4
|
|
5
5
|
内容としましては動画のフィールドに項目がある場合は動画を表示させて、動画が無い場合は画像を表示させたいです。
|
6
6
|
|
7
|
-
cssでclassを分けたいのでdiv単位で分けたいです。
|
8
|
-
|
9
|
-
現在はyoutube(動画)の部分だけ出力されていて、img(画像)の中身が空の状態です。
|
10
|
-
|
11
|
-
ご教授のほどよろしくお願いいたしますm(_ _)m
|
12
|
-
|
13
|
-
コードは以下の内容です。
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
<?php
|
20
|
-
|
21
|
-
// ループ条件を設定
|
22
|
-
|
23
|
-
|
7
|
+
どんな方法があるでしょうか?
|
24
|
-
|
25
|
-
'post_type' => array ('graphic','video','web'), /* 投稿タイプを指定 */
|
26
|
-
|
27
|
-
'paged' => get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1,
|
28
|
-
|
29
|
-
'posts_per_page' => 10, // 表示件数
|
30
|
-
|
31
|
-
'order' => 'date',
|
32
|
-
|
33
|
-
'order' => 'DESC',
|
34
|
-
|
35
|
-
);
|
36
|
-
|
37
|
-
?>
|
38
|
-
|
39
|
-
```
|
40
|
-
|
41
|
-
↑page.phpで記事の一覧を取得
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
```
|
46
|
-
|
47
|
-
<div class="clearfix">
|
48
|
-
|
49
|
-
<?php query_posts( $args ); ?>
|
50
|
-
|
51
|
-
<?php if (have_posts()) : ?>
|
52
|
-
|
53
|
-
<?php while (have_posts()) : the_post(); ?>
|
54
|
-
|
55
|
-
<div class="works">
|
56
|
-
|
57
|
-
<?php $youtube = get_post_meta($post->ID, 'youtube', true); ?>
|
58
|
-
|
59
|
-
<?php if(!empty($youtube)):?>
|
60
|
-
|
61
|
-
<div class="VideoWrapper">
|
62
|
-
|
63
|
-
<?php echo $embed_code = wp_oembed_get( get_field('youtube') ); ?>
|
64
|
-
|
65
|
-
</div>
|
66
|
-
|
67
|
-
<?php else:?>
|
68
|
-
|
69
|
-
<div class="worksImg">
|
70
|
-
|
71
|
-
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>" />
|
72
|
-
|
73
|
-
</div>
|
74
|
-
|
75
|
-
<?php endif; ?>
|
76
|
-
|
77
|
-
<div class="worksIco">
|
78
|
-
|
79
|
-
<h3><?php echo post_custom('crient'); ?></h3>
|
80
|
-
|
81
|
-
<p><?php echo post_custom('content'); ?></p>
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<?php endwhile; ?>
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<?php else : ?>
|
92
|
-
|
93
|
-
<h1>記事がありません</h1>
|
94
|
-
|
95
|
-
<p>表示する記事はありませんでした。</p>
|
96
|
-
|
97
|
-
<?php endif; ?>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
</div><!-- /clearfix -->
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
```
|
106
|
-
|
107
|
-
↑該当記事の出力
|
1
コード分けしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,13 +6,17 @@
|
|
6
6
|
|
7
7
|
cssでclassを分けたいのでdiv単位で分けたいです。
|
8
8
|
|
9
|
+
現在はyoutube(動画)の部分だけ出力されていて、img(画像)の中身が空の状態です。
|
10
|
+
|
9
11
|
ご教授のほどよろしくお願いいたしますm(_ _)m
|
10
12
|
|
11
13
|
コードは以下の内容です。
|
12
14
|
|
13
15
|
|
14
16
|
|
17
|
+
```
|
18
|
+
|
15
|
-
|
19
|
+
<?php
|
16
20
|
|
17
21
|
// ループ条件を設定
|
18
22
|
|
@@ -32,7 +36,13 @@
|
|
32
36
|
|
33
37
|
?>
|
34
38
|
|
39
|
+
```
|
35
40
|
|
41
|
+
↑page.phpで記事の一覧を取得
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```
|
36
46
|
|
37
47
|
<div class="clearfix">
|
38
48
|
|
@@ -58,9 +68,7 @@
|
|
58
68
|
|
59
69
|
<div class="worksImg">
|
60
70
|
|
61
|
-
<?php $img = get_post_meta($post->ID, 'img', true); ?>
|
62
|
-
|
63
|
-
<
|
71
|
+
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>" />
|
64
72
|
|
65
73
|
</div>
|
66
74
|
|
@@ -91,3 +99,9 @@
|
|
91
99
|
|
92
100
|
|
93
101
|
</div><!-- /clearfix -->
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
↑該当記事の出力
|