回答編集履歴
3
test
CHANGED
@@ -1,55 +1,5 @@
|
|
1
1
|
最初の回答は忘れてください。
|
2
2
|
|
3
|
+
更に更に訂正しておきます。
|
3
4
|
|
4
|
-
|
5
|
-
更に訂正しておきます。
|
6
|
-
|
7
|
-
functions.php
|
8
|
-
|
9
|
-
```
|
10
|
-
|
11
|
-
function tantou_shortcode( $tag ){
|
12
|
-
|
13
|
-
$fields = get_field( 'co_tantou' );
|
14
|
-
|
15
|
-
if( $fields ) {
|
16
|
-
|
17
|
-
$html = '<select name="'.$tag['name'].'">';
|
18
|
-
|
19
|
-
foreach( $fields as $field ) {
|
20
|
-
|
21
|
-
$html .= '<option value="'. $field['co_tantou_sub']. '">' . $field['co_tantou_sub']. '</option>';
|
22
|
-
|
23
|
-
}
|
24
|
-
|
25
|
-
|
5
|
+
必要なページの内容を出力して渡すのではなく、問い合わせページで出力すれば良いでしょう。
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
return $html;
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
wpcf7_add_form_tag( 'select_tantou', 'tantou_shortcode' ,true);
|
34
|
-
|
35
|
-
```
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
フォーム
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
[select_tantou tantou]
|
44
|
-
|
45
|
-
```
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
メッセージ本文
|
50
|
-
|
51
|
-
```
|
52
|
-
|
53
|
-
[tantou]
|
54
|
-
|
55
|
-
```
|
2
test
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
最初の回答は忘れてください。
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
更に訂正しておきます。
|
4
6
|
|
5
7
|
functions.php
|
6
8
|
|
7
9
|
```
|
8
10
|
|
9
|
-
function tantou_shortcode(){
|
11
|
+
function tantou_shortcode( $tag ){
|
10
12
|
|
11
13
|
$fields = get_field( 'co_tantou' );
|
12
14
|
|
13
15
|
if( $fields ) {
|
14
16
|
|
15
|
-
$html = '<select name="
|
17
|
+
$html = '<select name="'.$tag['name'].'">';
|
16
18
|
|
17
19
|
foreach( $fields as $field ) {
|
18
20
|
|
@@ -28,18 +30,26 @@
|
|
28
30
|
|
29
31
|
}
|
30
32
|
|
31
|
-
wpcf7_add_form_tag( 'tantou', 'tantou_shortcode' );
|
33
|
+
wpcf7_add_form_tag( 'select_tantou', 'tantou_shortcode' ,true);
|
32
34
|
|
33
35
|
```
|
34
36
|
|
35
37
|
|
36
38
|
|
39
|
+
フォーム
|
40
|
+
|
41
|
+
```
|
42
|
+
|
37
|
-
|
43
|
+
[select_tantou tantou]
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
メッセージ本文
|
38
50
|
|
39
51
|
```
|
40
52
|
|
41
53
|
[tantou]
|
42
54
|
|
43
55
|
```
|
44
|
-
|
45
|
-
こんな感じで出力は出来ると思うので、後の挙動は調整してください。
|
1
test
CHANGED
@@ -1,89 +1,45 @@
|
|
1
|
-
|
1
|
+
最初の回答は忘れてください。
|
2
|
+
|
3
|
+
|
2
4
|
|
3
5
|
functions.php
|
4
6
|
|
5
7
|
```
|
6
8
|
|
7
|
-
function
|
9
|
+
function tantou_shortcode(){
|
8
10
|
|
9
|
-
i
|
11
|
+
$fields = get_field( 'co_tantou' );
|
10
12
|
|
11
|
-
|
13
|
+
if( $fields ) {
|
12
14
|
|
13
|
-
|
15
|
+
$html = '<select name="co_tantou_sub">';
|
14
16
|
|
15
|
-
$
|
17
|
+
foreach( $fields as $field ) {
|
16
18
|
|
17
|
-
i
|
19
|
+
$html .= '<option value="'. $field['co_tantou_sub']. '">' . $field['co_tantou_sub']. '</option>';
|
18
20
|
|
21
|
+
}
|
22
|
+
|
19
|
-
$t
|
23
|
+
$html .= '</select>';
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
return $html;
|
20
28
|
|
21
29
|
}
|
22
30
|
|
23
|
-
if(isset($_POST['co_address'])){
|
24
|
-
|
25
|
-
$name = $tag['name'];
|
26
|
-
|
27
|
-
if($name == 'co_address')
|
28
|
-
|
29
|
-
$tag['values'] = (array) $_POST['co_address'];
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
if(isset($_POST['co_tantou_sub'])){
|
34
|
-
|
35
|
-
if($name == 'co_tantou_sub')
|
36
|
-
|
37
|
-
$tag['values'] = (array) $_POST['co_tantou_sub'];
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
return $tag;
|
42
|
-
|
43
|
-
}
|
44
|
-
|
45
|
-
|
31
|
+
wpcf7_add_form_tag( 'tantou', 'tantou_shortcode' );
|
46
32
|
|
47
33
|
```
|
48
34
|
|
49
35
|
|
50
36
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
管理画面のContact Form 7のフォームで表示させたい箇所に
|
56
38
|
|
57
39
|
```
|
58
40
|
|
59
|
-
<form action="<?php echo home_url(); ?>orderform/" method="post">
|
60
|
-
|
61
|
-
<input type="hidden" name="co_company" value="<?php the_field('co_company'); ?>">
|
62
|
-
|
63
|
-
<input type="hidden" name="co_address" value="<?php the_field('co_address'); ?>">
|
64
|
-
|
65
|
-
<select name="co_tantou_sub">
|
66
|
-
|
67
|
-
<?php if( have_rows( 'co_tantou' ) ): while( have_rows( 'co_tantou' ) ) : the_row(); ?>
|
68
|
-
|
69
|
-
<option value="<?php the_sub_field( 'co_tantou_sub' ); ?>"><?php the_sub_field( 'co_tantou_sub' ); ?></option>
|
70
|
-
|
71
|
-
<?php endwhile; endif; ?>
|
72
|
-
|
73
|
-
</select>
|
74
|
-
|
75
|
-
<button type="submit" value="">お問合せ</button>
|
76
|
-
|
77
|
-
|
41
|
+
[tantou]
|
78
42
|
|
79
43
|
```
|
80
44
|
|
81
|
-
|
82
|
-
|
83
|
-
Contact Form 7
|
84
|
-
|
85
|
-
```
|
86
|
-
|
87
|
-
|
45
|
+
こんな感じで出力は出来ると思うので、後の挙動は調整してください。
|
88
|
-
|
89
|
-
```
|