回答編集履歴

1

2017/10/30 08:11

投稿

退会済みユーザー
test CHANGED
@@ -117,3 +117,43 @@
117
117
  add_shortcode('shortcode4', 'shortcode4');
118
118
 
119
119
  ```
120
+
121
+
122
+
123
+ いまいちよく分からないですが、こういうことですか?
124
+
125
+ ```
126
+
127
+ function shortcode() {
128
+
129
+ require_once("phpQuery-onefile.php");
130
+
131
+ if(is_page('1')){
132
+
133
+ $html = file_get_contents("URL1");
134
+
135
+ }elseif(is_page('2')){
136
+
137
+ $html = file_get_contents("URL2");
138
+
139
+ }else{
140
+
141
+ $html = file_get_contents("URL3");
142
+
143
+ }
144
+
145
+ $id = phpQuery::newDocument($html)->find("#id名")->text();
146
+
147
+ $id2 = phpQuery::newDocument($html)->find("#id名2")->text();
148
+
149
+ $id3 = phpQuery::newDocument($html)->find("#id名3")->text();
150
+
151
+ $id4 = phpQuery::newDocument($html)->find("#id名4")->text();
152
+
153
+ return $id.$id2.$id3.$id4;
154
+
155
+ }
156
+
157
+ add_shortcode('shortcode', 'shortcode');
158
+
159
+ ```