質問編集履歴
2
全体的なソースコードを修正/エラーは消えたため削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
|
12
12
|
分かりにくい内容で申し訳ありませんが、ご教示の程よろしくお願いいたします。
|
13
13
|
|
14
|
+
** (2018/10/17 14:00 ソースコードを修正しました) **
|
15
|
+
|
14
16
|
### 該当のソースコード
|
15
17
|
|
16
18
|
```php
|
@@ -22,35 +24,61 @@
|
|
22
24
|
return ob_get_clean();
|
23
25
|
}
|
24
26
|
add_shortcode('hoge', 'my_php_Include');
|
25
|
-
|
27
|
+
```
|
28
|
+
```php
|
26
29
|
//hoge.php
|
27
|
-
<?php
|
30
|
+
<?php
|
28
31
|
$hogeargs = array(
|
29
|
-
'posts_per_page' =>
|
32
|
+
'posts_per_page' => 4,
|
30
33
|
'offset' => 0,
|
31
|
-
'
|
34
|
+
'orderby' => 'post_date',
|
32
|
-
'order' => '
|
35
|
+
'order' => 'DESC',
|
33
|
-
'post_type' =>
|
36
|
+
'post_type' => 'hogehoge',
|
34
37
|
'post_status' => 'publish',
|
35
38
|
'suppress_filters' => true,
|
39
|
+
'ignore_sticky_posts' => true,
|
40
|
+
'no_found_rows' => true
|
36
41
|
);
|
37
42
|
$hogePosts = get_posts($hogeargs);
|
38
|
-
|
43
|
+
if($hogePosts): ?>
|
39
|
-
|
44
|
+
<?php if($hogePosts) : foreach($hogePosts as $post) : setup_postdata( $post ); ?>
|
45
|
+
<?php
|
46
|
+
//データ取得(Advanced custom field)
|
47
|
+
$data_a = get_field('data_a');
|
48
|
+
$data_b = get_field('data_b');
|
49
|
+
$data_c = get_field('data_c');
|
50
|
+
$data_d = get_field('data_d');
|
51
|
+
$data_e = get_field('data_e');
|
52
|
+
$data_f = get_field('data_f');
|
53
|
+
?>
|
54
|
+
<img src="<?php $data_a; ?>">
|
40
|
-
|
55
|
+
<?php the_title(); ?> //タイトルは出ますが「ショートコードを設置した固定ページのタイトル」が出る
|
56
|
+
<p>
|
57
|
+
<?php if($data_b === 'aa'){
|
58
|
+
echo '◯';
|
59
|
+
} elseif($data_b === 'bb'){
|
60
|
+
echo '●';
|
61
|
+
} ?>
|
62
|
+
/<?php echo $data_c; ?></p>
|
63
|
+
<?php
|
64
|
+
if(!empty($data_d)){
|
65
|
+
if( in_array( 'cc', $data_d ) ) {
|
66
|
+
echo '□';
|
67
|
+
}
|
68
|
+
if( in_array( 'dd', $data_d ) ) {
|
69
|
+
echo '■';
|
70
|
+
}
|
71
|
+
} ?>
|
72
|
+
<p><?php echo $data_e; ?></p>
|
73
|
+
<p><?php echo $data_f; ?></p>
|
41
|
-
|
74
|
+
<?php endforeach; ?>
|
42
|
-
<?php endif;
|
75
|
+
<?php endif; ?>
|
43
|
-
|
76
|
+
<?php endif; ?>
|
44
77
|
```
|
45
78
|
```html
|
46
|
-
[
|
79
|
+
[hoge file='hoge']
|
47
80
|
```
|
48
81
|
|
49
|
-
### エラーコード
|
50
|
-
```
|
51
|
-
Warning: include(/home/httpd/html-ssl/www/hogehoge/wp-content/themes/hoge-theme/hoge.php) [function.include]: failed to open stream: No such file or directory in /home/httpd/html-ssl/www/hogehoge/wp-content/themes/hoge-theme/functions.php on line
|
52
|
-
Warning: include() [function.include]: Failed opening '/home/httpd/html-ssl/www/hogehoge/wp-content/themes/hoge-theme/hoge.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/httpd/html-ssl/www/hogehoge/wp-content/themes/hoge-theme/functions.php on line
|
53
|
-
```
|
54
82
|
### 試したこと
|
55
83
|
|
56
84
|
・ショートコードの中身(ただのテキスト)を表示させるところまではできました。
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
```
|
45
45
|
```html
|
46
|
-
[
|
46
|
+
[my_php_Include file='hoge']
|
47
47
|
```
|
48
48
|
|
49
49
|
### エラーコード
|