質問編集履歴

2

エラー文追加

2016/06/27 10:03

投稿

tree_tree
tree_tree

スコア22

test CHANGED
File without changes
test CHANGED
@@ -57,3 +57,131 @@
57
57
  記述している位置は間違ってないと思います。
58
58
 
59
59
  他にも色々とfunctionに記述しているため
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+ エラー文
68
+
69
+
70
+
71
+ Fatal error: Cannot redeclare my_form_tag_filter() (previously declared in /home/fajob/fajob00001/www/wp-vn/wp-content/themes/hemingway/functions.php:3) in /home/fajob/fajob00001/www/wp-vn/wp-content/themes/hemingway/functions.php on line 49
72
+
73
+
74
+
75
+
76
+
77
+ ```
78
+
79
+ function my_form_tag_filter($tag){
80
+
81
+ if ( ! is_array( $tag ) )
82
+
83
+ return $tag;
84
+
85
+ if(isset($_POST['goods_title'])){
86
+
87
+ $name = $tag['name'];
88
+
89
+ if($name == 'goods_title')
90
+
91
+ $tag['values'] = (array) $_POST['goods_title'];
92
+
93
+ }
94
+
95
+ if(isset($_POST['goods_code'])){
96
+
97
+ $name = $tag['name'];
98
+
99
+ if($name == 'goods_code')
100
+
101
+ $tag['values'] = (array) $_POST['goods_code'];
102
+
103
+ }
104
+
105
+ return $tag;
106
+
107
+ }
108
+
109
+ add_filter('wpcf7_form_tag', 'my_form_tag_filter');
110
+
111
+
112
+
113
+
114
+
115
+ //管理画面editor削除
116
+
117
+ add_action( 'init' , 'my_remove_post_editor_support' );
118
+
119
+
120
+
121
+ function my_remove_post_editor_support() {
122
+
123
+ remove_post_type_support( 'post', 'editor' );
124
+
125
+ }
126
+
127
+
128
+
129
+ //ショートコードを使ったphpファイルの呼び出し方法
130
+
131
+ function Include_my_php($params = array()) {
132
+
133
+ extract(shortcode_atts(array(
134
+
135
+ 'file' => 'default'
136
+
137
+ ), $params));
138
+
139
+ ob_start();
140
+
141
+ include(get_theme_root() . '/' . get_template() . "/$file.php");
142
+
143
+ return ob_get_clean();
144
+
145
+ }
146
+
147
+ add_shortcode('myphp', 'Include_my_php');
148
+
149
+
150
+
151
+ function my_form_tag_filter($tag){
152
+
153
+ if ( ! is_array( $tag ) )
154
+
155
+ return $tag;
156
+
157
+
158
+
159
+ if(isset($_GET['goods'])){
160
+
161
+ $name = $tag['name'];
162
+
163
+ if($name == 'goods')
164
+
165
+ $tag['values'] = (array) $_GET['goods'];
166
+
167
+ }
168
+
169
+ return $tag;
170
+
171
+ }
172
+
173
+ ```
174
+
175
+
176
+
177
+ 49行目まで記載
178
+
179
+ 一番下の
180
+
181
+ function my_form_tag_filter($tag)・・・を消すと
182
+
183
+ エラーは消えます。
184
+
185
+
186
+
187
+ 何が原因なんでしょうか?

1

コードブロック追加

2016/06/27 10:02

投稿

tree_tree
tree_tree

スコア22

test CHANGED
File without changes
test CHANGED
@@ -11,6 +11,8 @@
11
11
  なぜでしょうか?
12
12
 
13
13
 
14
+
15
+ ```
14
16
 
15
17
  function my_form_tag_filter($tag){
16
18
 
@@ -44,6 +46,8 @@
44
46
 
45
47
  add_filter('wpcf7_form_tag', 'my_form_tag_filter');
46
48
 
49
+ ```
50
+
47
51
 
48
52
 
49
53