質問編集履歴

2

削除の取り消し

2016/01/13 06:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1 +1,81 @@
1
+ Wordpressでショートコードを作成したいのですがなかなか上手く行かず困っており、ご教授を御願いしたく書き込みさせて頂きます。
2
+
3
+
4
+
5
+ 現在プラグインのExec-PHPを使って投稿画面の本文欄に下記のPHPを直接的に書き込んでいるのですが、第3者にもこの作業をやってもらうに当たり、出来るだけ簡略化したく、これをショートコード化したいのですが四苦八苦している状態です。
6
+
7
+
8
+
1
- サイト仕様上、削除がいようすのが、このまま放置す気が引けるのでこで〆ます。閲覧ありがとうございした
9
+ 下記コードfeed1~feed6の部分は固定くfeed7やfeed10まば、feed1しかない場合もありま
10
+
11
+
12
+
13
+ 手短ではありますが、ご教授の程、宜しく御願い致します。
14
+
15
+
16
+
17
+ ```
18
+
19
+ <?php include_once(ABSPATH . WPINC . '/feed.php');
20
+
21
+ $rss = fetch_feed(array(
22
+
23
+ //以下にブログのRSS Feedを記述(複数の場合はカンマ区切り)
24
+
25
+ 'http://kotori-blog.com/feed1',
26
+
27
+ 'http://kotori-blog.com/feed2',
28
+
29
+ 'http://kotori-blog.com/feed3',
30
+
31
+ 'http://kotori-blog.com/feed4',
32
+
33
+ 'http://kotori-blog.com/feed5',
34
+
35
+ 'http://kotori-blog.com/feed6'
36
+
37
+ ));
38
+
39
+ if (!is_wp_error( $rss ) ) :
40
+
41
+ $rss->set_cache_duration(1800);
42
+
43
+ $rss->init();
44
+
45
+ $maxitems = $rss->get_item_quantity(10);
46
+
47
+ $rss_items = $rss->get_items(0, $maxitems);
48
+
49
+ date_default_timezone_set('Asia/Tokyo');
50
+
51
+ endif;
52
+
53
+ ?>
54
+
55
+ //ここから表示部分の記述
56
+
57
+ <?php echo '<h5>Latest ' . $maxitems . ' Posts</h5>'; ?>
58
+
59
+ <dl>
60
+
61
+ <?php if ($maxitems == 0) echo '<dt>No items.</dt>';
62
+
63
+ else
64
+
65
+ foreach ( $rss_items as $item ) : ?>
66
+
67
+ <dt><?php echo $item->get_feed()->get_title(); ?></dt>
68
+
69
+ <dd>
70
+
71
+ <a href='<?php echo $item->get_permalink(); ?>' target="_blank"><?php echo $item->get_title(); ?></a><br />
72
+
73
+ <?php echo $item->get_date("Y-n-j"); ?>
74
+
75
+ </dd>
76
+
77
+ <?php endforeach; ?>
78
+
79
+ </dl>
80
+
81
+ ```

1

本文修正

2016/01/13 06:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,77 +1 @@
1
- Wordpressでショートコードを作成したいのですがなかなか上手く行かず困っており、ご教授を御願いしたく書き込みさせて頂きます。
2
-
3
-
4
-
5
- 現在プラグインのExec-PHPを使って投稿画面の本文欄に下記のPHPを直接的に書き込んでいるのですが、第3者にもこの作業をやってもらうに当たり、出来るだけ簡略化したく、これをショートコード化したいのですが四苦八苦している状態です。
6
-
7
-
8
-
9
- 下記コードfeed1~feed6の部分は固定くfeed7やfeed10であば、feed1しかない場合もありま
1
+ サイト仕様上、削除がいようですのが、このま放置す気が引けるのでこで〆ます。閲覧ありがとうございした
10
-
11
-
12
-
13
- 手短ではありますが、ご教授の程、宜しく御願い致します。
14
-
15
-
16
-
17
- <?php include_once(ABSPATH . WPINC . '/feed.php');
18
-
19
- $rss = fetch_feed(array(
20
-
21
- //以下にブログのRSS Feedを記述(複数の場合はカンマ区切り)
22
-
23
- 'http://kotori-blog.com/feed1',
24
-
25
- 'http://kotori-blog.com/feed2',
26
-
27
- 'http://kotori-blog.com/feed3',
28
-
29
- 'http://kotori-blog.com/feed4',
30
-
31
- 'http://kotori-blog.com/feed5',
32
-
33
- 'http://kotori-blog.com/feed6'
34
-
35
- ));
36
-
37
- if (!is_wp_error( $rss ) ) :
38
-
39
- $rss->set_cache_duration(1800);
40
-
41
- $rss->init();
42
-
43
- $maxitems = $rss->get_item_quantity(10);
44
-
45
- $rss_items = $rss->get_items(0, $maxitems);
46
-
47
- date_default_timezone_set('Asia/Tokyo');
48
-
49
- endif;
50
-
51
- ?>
52
-
53
- //ここから表示部分の記述
54
-
55
- <?php echo '<h5>Latest ' . $maxitems . ' Posts</h5>'; ?>
56
-
57
- <dl>
58
-
59
- <?php if ($maxitems == 0) echo '<dt>No items.</dt>';
60
-
61
- else
62
-
63
- foreach ( $rss_items as $item ) : ?>
64
-
65
- <dt><?php echo $item->get_feed()->get_title(); ?></dt>
66
-
67
- <dd>
68
-
69
- <a href='<?php echo $item->get_permalink(); ?>' target="_blank"><?php echo $item->get_title(); ?></a><br />
70
-
71
- <?php echo $item->get_date("Y-n-j"); ?>
72
-
73
- </dd>
74
-
75
- <?php endforeach; ?>
76
-
77
- </dl>