質問編集履歴
2
運用しているサイトを記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -219,4 +219,16 @@
|
|
219
219
|
4ページ
|
220
220
|
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/4/
|
221
221
|
|
222
|
-
上記の様にディレクトリの最後に数字が増えていく状態になっております。
|
222
|
+
上記の様にディレクトリの最後に数字が増えていく状態になっております。
|
223
|
+
|
224
|
+
---------------------追加です!!!---------------------
|
225
|
+
|
226
|
+
https://soysauce-mg.com
|
227
|
+
運用しているサイトはこちらです。
|
228
|
+
|
229
|
+
https://soysauce-mg.com/2018/10/11/doikouza002/
|
230
|
+
|
231
|
+
サイト内の記事は
|
232
|
+
wordpress内のテキストで
|
233
|
+
<!--nextpage-->
|
234
|
+
を使用して次のページに切り替わる設定にしています。
|
1
codeの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,4 +31,192 @@
|
|
31
31
|
|
32
32
|
どなたか2ページ目以降もRSSで取得する方法を教えて頂けませんか?
|
33
33
|
|
34
|
-
よろしくお願いいたします。
|
34
|
+
よろしくお願いいたします。
|
35
|
+
|
36
|
+
---------------------追加です!!!---------------------
|
37
|
+
|
38
|
+
> 具体的なコードの全体を記載してください。
|
39
|
+
|
40
|
+
```<?php
|
41
|
+
/**
|
42
|
+
* RSS2 Feed Template for displaying RSS2 Posts feed.
|
43
|
+
*
|
44
|
+
* @package smartnews
|
45
|
+
*/
|
46
|
+
|
47
|
+
header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
|
48
|
+
$more = 1;
|
49
|
+
|
50
|
+
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Fires between the xml and rss tags in a feed.
|
54
|
+
*
|
55
|
+
* @since 4.0.0
|
56
|
+
*
|
57
|
+
* @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
|
58
|
+
* 'rdf', 'atom', and 'atom-comments'.
|
59
|
+
*/
|
60
|
+
do_action( 'rss_tag_pre', 'rss2' );
|
61
|
+
?>
|
62
|
+
<rss version="2.0"
|
63
|
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
64
|
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
65
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
66
|
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
67
|
+
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
68
|
+
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
69
|
+
xmlns:media="http://search.yahoo.com/mrss/"
|
70
|
+
xmlns:snf="http://www.smartnews.be/snf"
|
71
|
+
<?php
|
72
|
+
/**
|
73
|
+
* Fires at the end of the RSS root to add namespaces.
|
74
|
+
*
|
75
|
+
* @since 2.0.0
|
76
|
+
*/
|
77
|
+
do_action( 'rss2_ns' );
|
78
|
+
?>
|
79
|
+
>
|
80
|
+
<channel>
|
81
|
+
<title><?php echo bloginfo('name'); ?></title>
|
82
|
+
<snf:logo><url>画像URL</url></snf:logo>
|
83
|
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
84
|
+
<link><?php bloginfo_rss('url') ?></link>
|
85
|
+
<description><?php bloginfo_rss("description") ?></description>
|
86
|
+
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
|
87
|
+
<language><?php bloginfo_rss( 'language' ); ?></language>
|
88
|
+
<sy:updatePeriod><?php
|
89
|
+
$duration = 'hourly';
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Filter how often to update the RSS feed.
|
93
|
+
*
|
94
|
+
* @since 2.1.0
|
95
|
+
*
|
96
|
+
* @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
|
97
|
+
* 'yearly'. Default 'hourly'.
|
98
|
+
*/
|
99
|
+
echo apply_filters( 'rss_update_period', $duration );
|
100
|
+
?></sy:updatePeriod>
|
101
|
+
<sy:updateFrequency><?php
|
102
|
+
$frequency = '1';
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Filter the RSS update frequency.
|
106
|
+
*
|
107
|
+
* @since 2.1.0
|
108
|
+
*
|
109
|
+
* @param string $frequency An integer passed as a string representing the frequency
|
110
|
+
* of RSS updates within the update period. Default '1'.
|
111
|
+
*/
|
112
|
+
echo apply_filters( 'rss_update_frequency', $frequency );
|
113
|
+
?></sy:updateFrequency>
|
114
|
+
|
115
|
+
<copyright><?php echo get_theme_mod('copy_right_setting'); ?></copyright>
|
116
|
+
<ttl>15</ttl>
|
117
|
+
<image>
|
118
|
+
<url><?php echo esc_url( get_theme_mod( LOGO_IMAGE_URL ) ); ?></url>
|
119
|
+
<title><?php echo bloginfo('name'); ?></title>
|
120
|
+
<link><?php echo site_url(); ?></link>
|
121
|
+
</image>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<?php
|
126
|
+
/**
|
127
|
+
* Fires at the end of the RSS2 Feed Header.
|
128
|
+
*
|
129
|
+
* @since 2.0.0
|
130
|
+
*/
|
131
|
+
do_action( 'rss2_head');
|
132
|
+
|
133
|
+
while( have_posts()) : the_post();
|
134
|
+
?>
|
135
|
+
<item>
|
136
|
+
<title><?php the_title_rss() ?></title>
|
137
|
+
<link><?php the_permalink_rss() ?></link>
|
138
|
+
<?php if ( get_comments_number() || comments_open() ) : ?>
|
139
|
+
<comments><?php comments_link_feed(); ?></comments>
|
140
|
+
<?php endif; ?>
|
141
|
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
|
142
|
+
<?php
|
143
|
+
$thumb_id = get_post_thumbnail_id();
|
144
|
+
$thumb_url = wp_get_attachment_image_src($thumb_id, 'full');
|
145
|
+
?>
|
146
|
+
<?php if(!empty($thumb_url[0])){ ?>
|
147
|
+
<media:thumbnail url="<?php echo $thumb_url[0] ?>" />
|
148
|
+
<snf:analytics><![CDATA[<script><!-- Analytics埋め込み --></script>]]></snf:analytics>
|
149
|
+
<?php } ?>
|
150
|
+
|
151
|
+
<?php the_category_rss('rss2') ?>
|
152
|
+
|
153
|
+
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
154
|
+
<?php if (get_option('rss_use_excerpt')) : ?>
|
155
|
+
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
|
156
|
+
<?php else : ?>
|
157
|
+
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
|
158
|
+
<?php $content = get_the_content_feed('rss2'); ?>
|
159
|
+
<?php if ( strlen( $content ) > 0 ) : ?>
|
160
|
+
<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
|
161
|
+
<?php else : ?>
|
162
|
+
<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
|
163
|
+
<?php endif; ?>
|
164
|
+
<?php endif; ?>
|
165
|
+
<?php if ( get_comments_number() || comments_open() ) : ?>
|
166
|
+
<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
|
167
|
+
<slash:comments><?php echo get_comments_number(); ?></slash:comments>
|
168
|
+
|
169
|
+
<?php
|
170
|
+
$cat_data = get_the_category();
|
171
|
+
$cat_list = get_category($cat_data);
|
172
|
+
|
173
|
+
$query = new WP_Query(
|
174
|
+
array(
|
175
|
+
'cat' => $cat_list->cat_ID,
|
176
|
+
'post__not_in' => array($post->ID),
|
177
|
+
'posts_per_page' => '1',
|
178
|
+
'offset' => '1',
|
179
|
+
'post_type' => 'post',
|
180
|
+
'orderby' => 'rand'
|
181
|
+
));
|
182
|
+
|
183
|
+
while($query->have_posts()):$query->the_post();
|
184
|
+
|
185
|
+
$rel_thumb_id = get_post_thumbnail_id();
|
186
|
+
$rel_thumb_url = wp_get_attachment_image_src($rel_thumb_id, 'full');
|
187
|
+
?>
|
188
|
+
|
189
|
+
<snf:relatedLink title="<?php echo the_title_attribute(); ?>" link="<?php the_permalink(); ?>" thumbnail="<?php echo $rel_thumb_url[0]; ?>" />
|
190
|
+
<?php endwhile; ?>
|
191
|
+
<?php wp_reset_postdata(); ?>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<?php endif; ?>
|
196
|
+
<?php rss_enclosure(); ?>
|
197
|
+
<?php
|
198
|
+
/**
|
199
|
+
* Fires at the end of each RSS2 feed item.
|
200
|
+
*
|
201
|
+
* @since 2.0.0
|
202
|
+
*/
|
203
|
+
do_action( 'rss2_item' );
|
204
|
+
?>
|
205
|
+
</item>
|
206
|
+
<?php endwhile; ?>
|
207
|
+
</channel>
|
208
|
+
</rss>
|
209
|
+
```
|
210
|
+
↑ ↑ ↑
|
211
|
+
こういったPHPになっています。
|
212
|
+
|
213
|
+
> 2ページ目以降
|
214
|
+
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/2/
|
215
|
+
|
216
|
+
3ページ
|
217
|
+
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/3/
|
218
|
+
|
219
|
+
4ページ
|
220
|
+
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/4/
|
221
|
+
|
222
|
+
上記の様にディレクトリの最後に数字が増えていく状態になっております。
|