回答編集履歴
6
コード修正
test
CHANGED
@@ -62,11 +62,15 @@
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
+
// ここからメイン
|
66
|
+
|
65
67
|
$post_next = TRUE;
|
66
68
|
|
67
|
-
|
69
|
+
$have_posts_checked = have_posts();
|
68
70
|
|
71
|
+
while(TRUE) {
|
72
|
+
|
69
|
-
if(have_posts
|
73
|
+
if($have_posts_checked) {
|
70
74
|
|
71
75
|
if($post_next) {
|
72
76
|
|
@@ -74,13 +78,17 @@
|
|
74
78
|
|
75
79
|
$post_next = FALSE;
|
76
80
|
|
81
|
+
$have_posts_checked = have_posts();
|
82
|
+
|
77
83
|
}
|
78
84
|
|
79
|
-
if($counter >= count($feed_items) || get_the_date()
|
85
|
+
if($counter >= count($feed_items) || strcmp(get_the_date('Ymd'), $feed_items[$counter]->get_date('Ymd')) > 0) {
|
80
86
|
|
81
|
-
the_
|
87
|
+
the_time('Y.m.d');
|
82
88
|
|
89
|
+
the_title();
|
90
|
+
|
83
|
-
|
91
|
+
echo '<br>';
|
84
92
|
|
85
93
|
$post_next = TRUE;
|
86
94
|
|
@@ -90,9 +98,9 @@
|
|
90
98
|
|
91
99
|
}
|
92
100
|
|
93
|
-
if($counter < count($feed_items) {
|
101
|
+
if($counter < count($feed_items)) {
|
94
102
|
|
95
|
-
printf('<span class="date">%s</span><br />', $feed_items[$counter]->get_date('Y.m.d'));
|
103
|
+
printf('<span class="date">%s</span>%s<br />', $feed_items[$counter]->get_date('Y.m.d'), $feed_items[$counter]->get_title());
|
96
104
|
|
97
105
|
++$counter;
|
98
106
|
|
5
the_post
test
CHANGED
@@ -62,15 +62,27 @@
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
+
$post_next = TRUE;
|
66
|
+
|
65
67
|
while(true) {
|
66
68
|
|
67
69
|
if(have_posts()) {
|
70
|
+
|
71
|
+
if($post_next) {
|
72
|
+
|
73
|
+
the_post();
|
74
|
+
|
75
|
+
$post_next = FALSE;
|
76
|
+
|
77
|
+
}
|
68
78
|
|
69
79
|
if($counter >= count($feed_items) || get_the_date() > $feed_items[$counter]->get_date()) {
|
70
80
|
|
71
81
|
the_post();
|
72
82
|
|
73
83
|
the_time("Y.m.j");
|
84
|
+
|
85
|
+
$post_next = TRUE;
|
74
86
|
|
75
87
|
continue;
|
76
88
|
|
4
ミス修正
test
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
if(have_posts()) {
|
68
68
|
|
69
|
-
if($counter >= count($feed_items) || get_the_date() > $item->get_date()) {
|
69
|
+
if($counter >= count($feed_items) || get_the_date() > $feed_items[$counter]->get_date()) {
|
70
70
|
|
71
71
|
the_post();
|
72
72
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
if($counter < count($feed_items) {
|
82
82
|
|
83
|
-
printf('<span class="date">%s</span><br />', $item->get_date('Y.m.d'));
|
83
|
+
printf('<span class="date">%s</span><br />', $feed_items[$counter]->get_date('Y.m.d'));
|
84
84
|
|
85
85
|
++$counter;
|
86
86
|
|
3
処理イメージ
test
CHANGED
@@ -16,6 +16,88 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
時間がないので、概要だけ…
|
22
|
+
|
23
|
+
```PHP
|
24
|
+
|
25
|
+
<?php
|
26
|
+
|
27
|
+
include_once(ABSPATH . WPINC . '/feed.php');
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
$display_posts_count = 20;
|
32
|
+
|
33
|
+
$get_posts_count = 40;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
query_posts('post_type=post&paged='.$paged);
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
$ameblo_feed = fetch_feed(array(
|
42
|
+
|
43
|
+
'http://feedblog.ameba.jp/rss/ameblo/', // feed1
|
44
|
+
|
45
|
+
// feed2'http://rssblog.ameba.jp/AmebloID/rss20.xml',
|
46
|
+
|
47
|
+
// feed3'http://rssblog.ameba.jp/AmebloID/rss20.xml'
|
48
|
+
|
49
|
+
));
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
$counter = 0;
|
54
|
+
|
55
|
+
if (!is_wp_error( $ameblo_feed ) ) :
|
56
|
+
|
57
|
+
$maxitems = $ameblo_feed->get_item_quantity($get_posts_count);
|
58
|
+
|
59
|
+
$feed_items = $ameblo_feed->get_items(0, $maxitems);
|
60
|
+
|
61
|
+
endif;
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
while(true) {
|
66
|
+
|
67
|
+
if(have_posts()) {
|
68
|
+
|
69
|
+
if($counter >= count($feed_items) || get_the_date() > $item->get_date()) {
|
70
|
+
|
71
|
+
the_post();
|
72
|
+
|
73
|
+
the_time("Y.m.j");
|
74
|
+
|
75
|
+
continue;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
if($counter < count($feed_items) {
|
82
|
+
|
83
|
+
printf('<span class="date">%s</span><br />', $item->get_date('Y.m.d'));
|
84
|
+
|
85
|
+
++$counter;
|
86
|
+
|
87
|
+
}else{
|
88
|
+
|
89
|
+
break;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
?>
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
19
101
|
---
|
20
102
|
|
21
103
|
[記事一覧をソート(並び替え)する](http://blog.anekipedia.com/cus/%E8%A8%98%E4%BA%8B%E4%B8%80%E8%A6%A7%E3%82%92%E3%82%BD%E3%83%BC%E3%83%88%EF%BC%88%E4%B8%A6%E3%81%B3%E6%9B%BF%E3%81%88%EF%BC%89%E3%81%99%E3%82%8B.html)
|
2
間違ったので修正
test
CHANGED
@@ -1,24 +1,18 @@
|
|
1
|
-
|
1
|
+
PHP でプログラミングする必要がありますね。
|
2
|
-
|
3
|
-
私の以下の回答と
|
4
|
-
|
5
|
-
https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/query_posts
|
6
|
-
|
7
|
-
をよく読んで下さい。
|
8
|
-
|
9
|
-
`<?php query_posts('post_type=post&paged='.$paged); ?>` を `<?php query_posts('post_type=post&orderby=date&paged='.$paged); ?>` ではだめですか?
|
10
|
-
|
11
|
-
http://www.understandard.net/wordpress/wp009.html
|
12
|
-
|
13
|
-
も読んでみたらいかがでしょうか。
|
14
2
|
|
15
3
|
|
16
4
|
|
5
|
+
0. while ループで処理するとよいでしょう
|
6
|
+
|
17
|
-
|
7
|
+
0. wordpress 側の最新記事と、feed 側の最新記事の時刻を比較します。新しい方を出力します。
|
8
|
+
|
9
|
+
the_time("Y.m.j") と $item->get_date('Y.m.d') とを比較することになるでしょう。
|
10
|
+
|
11
|
+
0. どちらかがなくなれば、もう片方をすべて出力します。
|
18
12
|
|
19
13
|
|
20
14
|
|
21
|
-
|
15
|
+
ループを一つにし、`the_post();` か `$item->get_title()` か、どちらかを用いるイメージですね。
|
22
16
|
|
23
17
|
|
24
18
|
|
1
query_posts
test
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
query_posts を使っているようなので…
|
2
|
+
|
3
|
+
私の以下の回答と
|
4
|
+
|
5
|
+
https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/query_posts
|
6
|
+
|
7
|
+
をよく読んで下さい。
|
8
|
+
|
9
|
+
`<?php query_posts('post_type=post&paged='.$paged); ?>` を `<?php query_posts('post_type=post&orderby=date&paged='.$paged); ?>` ではだめですか?
|
10
|
+
|
11
|
+
http://www.understandard.net/wordpress/wp009.html
|
12
|
+
|
13
|
+
も読んでみたらいかがでしょうか。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
> `query_posts` 等で取得する際に、`order` や `orderby` を与えると、並び替えができます。
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
という回答では不測でしたか?すみません…
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
---
|
26
|
+
|
1
27
|
[記事一覧をソート(並び替え)する](http://blog.anekipedia.com/cus/%E8%A8%98%E4%BA%8B%E4%B8%80%E8%A6%A7%E3%82%92%E3%82%BD%E3%83%BC%E3%83%88%EF%BC%88%E4%B8%A6%E3%81%B3%E6%9B%BF%E3%81%88%EF%BC%89%E3%81%99%E3%82%8B.html)
|
2
28
|
|
3
29
|
[WordPressで思った通りの順番で記事をソート](http://www.off-soft.net/blog/wordpress/sort_post.html)
|