質問編集履歴
6
試したことの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -194,7 +194,7 @@
|
|
194
194
|
|
195
195
|
}
|
196
196
|
|
197
|
-
add_shortcode('h
|
197
|
+
add_shortcode('shortcode1', 'shortcode1');
|
198
198
|
|
199
199
|
|
200
200
|
|
@@ -208,7 +208,7 @@
|
|
208
208
|
|
209
209
|
}
|
210
210
|
|
211
|
-
add_shortcode('h
|
211
|
+
add_shortcode('shortcode2', 'shortcode2');
|
212
212
|
|
213
213
|
|
214
214
|
|
@@ -222,7 +222,7 @@
|
|
222
222
|
|
223
223
|
}
|
224
224
|
|
225
|
-
add_shortcode('h
|
225
|
+
add_shortcode('shortcode3', 'shortcode3');
|
226
226
|
|
227
227
|
|
228
228
|
|
@@ -236,7 +236,7 @@
|
|
236
236
|
|
237
237
|
}
|
238
238
|
|
239
|
-
add_shortcode('h
|
239
|
+
add_shortcode('shortcode4', 'shortcode4');
|
240
240
|
|
241
241
|
|
242
242
|
|
5
試したことの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -156,7 +156,7 @@
|
|
156
156
|
|
157
157
|
```
|
158
158
|
|
159
|
-
###
|
159
|
+
###試したこと
|
160
160
|
|
161
161
|
```
|
162
162
|
|
4
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -128,10 +128,40 @@
|
|
128
128
|
|
129
129
|
```
|
130
130
|
|
131
|
+
###ay03様からいただいた回答の以下部分の処理をまとめたい
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
require_once("phpQuery-onefile.php");
|
138
|
+
|
139
|
+
if(is_page('1')){
|
140
|
+
|
141
|
+
$html = file_get_contents("URL1");
|
142
|
+
|
143
|
+
}elseif(is_page('2')){
|
144
|
+
|
145
|
+
$html = file_get_contents("URL2");
|
146
|
+
|
147
|
+
}else{
|
148
|
+
|
149
|
+
$html = file_get_contents("URL3");
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
$id1 = phpQuery::newDocument($html)->find("#id名1")->text();
|
154
|
+
|
155
|
+
return $id1;
|
156
|
+
|
157
|
+
```
|
158
|
+
|
131
159
|
###やってみたこと
|
132
160
|
|
133
161
|
```
|
134
162
|
|
163
|
+
function htmlurl($id, $htmlid) {
|
164
|
+
|
135
165
|
require_once("phpQuery-onefile.php");
|
136
166
|
|
137
167
|
if(is_page('1')){
|
@@ -144,12 +174,74 @@
|
|
144
174
|
|
145
175
|
}else{
|
146
176
|
|
147
|
-
$html = file_get_contents("
|
177
|
+
$html = file_get_contents("3");
|
148
|
-
|
178
|
+
|
149
|
-
}
|
179
|
+
}
|
150
|
-
|
180
|
+
|
151
|
-
$id
|
181
|
+
$id = phpQuery::newDocument($html)->find($htmlid)->text();
|
182
|
+
|
152
|
-
|
183
|
+
return $id;
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
htmlurl('$id1', '#id名1');
|
188
|
+
|
189
|
+
function shortcode1() {
|
190
|
+
|
191
|
+
global $id1;
|
192
|
+
|
193
|
+
return $id1;
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
add_shortcode('hytwin', 'shortcode1');
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
htmlurl('$id2', '#id名2');
|
202
|
+
|
203
|
+
function shortcode2() {
|
204
|
+
|
205
|
+
global $id2;
|
206
|
+
|
207
|
+
return $id2;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
add_shortcode('hytwin', 'shortcode2');
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
htmlurl('$id3', '#id名3');
|
216
|
+
|
217
|
+
function shortcode3() {
|
218
|
+
|
219
|
+
global $id3;
|
220
|
+
|
221
|
+
return $id3;
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
add_shortcode('hytwin', 'shortcode3');
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
htmlurl('$id4', '#id名4');
|
230
|
+
|
231
|
+
function shortcode4() {
|
232
|
+
|
233
|
+
global $id4;
|
234
|
+
|
153
|
-
return $id4;
|
235
|
+
return $id4;
|
236
|
+
|
154
|
-
|
237
|
+
}
|
238
|
+
|
239
|
+
add_shortcode('hytwin', 'shortcode4');
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
155
|
-
```
|
245
|
+
```
|
246
|
+
|
247
|
+
結果 空白
|
3
やってみたことの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,3 +127,29 @@
|
|
127
127
|
|
128
128
|
|
129
129
|
```
|
130
|
+
|
131
|
+
###やってみたこと
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
require_once("phpQuery-onefile.php");
|
136
|
+
|
137
|
+
if(is_page('1')){
|
138
|
+
|
139
|
+
$html = file_get_contents("URL1");
|
140
|
+
|
141
|
+
}elseif(is_page('2')){
|
142
|
+
|
143
|
+
$html = file_get_contents("URL2");
|
144
|
+
|
145
|
+
}else{
|
146
|
+
|
147
|
+
$html = file_get_contents("URL3");
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
$id4 = phpQuery::newDocument($html)->find("#id名4")->text();
|
152
|
+
|
153
|
+
return $id4;
|
154
|
+
|
155
|
+
```
|
2
```の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
※抽出元のHTMLは例とは別でそれぞれ若干違います。
|
34
34
|
|
35
|
-
|
35
|
+
```
|
36
36
|
|
37
37
|
###該当のソースコード
|
38
38
|
|
@@ -94,7 +94,9 @@
|
|
94
94
|
|
95
95
|
</ul>
|
96
96
|
|
97
|
+
```
|
97
98
|
|
99
|
+
```
|
98
100
|
|
99
101
|
WordPressのfunction.phpに記載してるもの
|
100
102
|
|
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -102,17 +102,17 @@
|
|
102
102
|
|
103
103
|
require_once("phpQuery-onefile.php");
|
104
104
|
|
105
|
-
if(is_page('1')){//固定ページ1だった場合は$htmlにURL1のサイトを
|
105
|
+
if(is_page('1')){ //固定ページ1だった場合は$htmlにURL1のサイトを
|
106
106
|
|
107
107
|
$html = file_get_contents("URL1");
|
108
108
|
|
109
109
|
}elseif(is_page('2')){
|
110
110
|
|
111
|
-
$html = file_get_contents("URL2");//固定ページ2だった場合は$htmlにURL2のサイトを
|
111
|
+
$html = file_get_contents("URL2"); //固定ページ2だった場合は$htmlにURL2のサイトを
|
112
112
|
|
113
113
|
}else{
|
114
114
|
|
115
|
-
$html = file_get_contents("URL3");その他の場合は$htmlにURL3のサイトを
|
115
|
+
$html = file_get_contents("URL3"); //その他の場合は$htmlにURL3のサイトを
|
116
116
|
|
117
117
|
}
|
118
118
|
|
@@ -120,7 +120,7 @@
|
|
120
120
|
|
121
121
|
}
|
122
122
|
|
123
|
-
add_shortcode('shortcode1', 'shortcode');
|
123
|
+
add_shortcode('shortcode1', 'shortcode'); id名〜id名4のショートコードを利用したい。
|
124
124
|
|
125
125
|
|
126
126
|
|