PHP初心者です。
現在私はワードプレスで作成しているまとめサイトを運用しています。
運用しているサイトをスマートニュースに掲載させたいと思っています。
http://flappe.guide-book.xyz/column/column-smartnews/
こちらのサイトを参考にスマートニュース用のPHPを作成しました。
チェックツールでは『Valid』(有効)と表示されたので、スマートニュースに申請したところ。
現在、フィード中の各記事が、(オリジナルサイトでの)冒頭ページまでで、途切れてしまっております。
とメールでいただきました。
ワードプレスので作成した記事の2ページ目以降が取得出来ず、表示されない状態になってしまっています。
content:encoded
この中に2ページ目以降も取得する記述がわかりません。
<content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded> <?php else : ?> <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> <?php endif; ?>
↑ ↑ ↑
ここを修正すればいいのかと思います。
どなたか2ページ目以降もRSSで取得する方法を教えて頂けませんか?
よろしくお願いいたします。
---------------------追加です!!!---------------------
具体的なコードの全体を記載してください。
/** * RSS2 Feed Template for displaying RSS2 Posts feed. * * @package smartnews */ header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true); $more = 1; echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; /** * Fires between the xml and rss tags in a feed. * * @since 4.0.0 * * @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments', * 'rdf', 'atom', and 'atom-comments'. */ do_action( 'rss_tag_pre', 'rss2' ); ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:snf="http://www.smartnews.be/snf" <?php /** * Fires at the end of the RSS root to add namespaces. * * @since 2.0.0 */ do_action( 'rss2_ns' ); ?> > <channel> <title><?php echo bloginfo('name'); ?></title> <snf:logo><url>画像URL</url></snf:logo> <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> <link><?php bloginfo_rss('url') ?></link> <description><?php bloginfo_rss("description") ?></description> <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> <language><?php bloginfo_rss( 'language' ); ?></language> <sy:updatePeriod><?php $duration = 'hourly'; /** * Filter how often to update the RSS feed. * * @since 2.1.0 * * @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly', * 'yearly'. Default 'hourly'. */ echo apply_filters( 'rss_update_period', $duration ); ?></sy:updatePeriod> <sy:updateFrequency><?php $frequency = '1'; /** * Filter the RSS update frequency. * * @since 2.1.0 * * @param string $frequency An integer passed as a string representing the frequency * of RSS updates within the update period. Default '1'. */ echo apply_filters( 'rss_update_frequency', $frequency ); ?></sy:updateFrequency> <copyright><?php echo get_theme_mod('copy_right_setting'); ?></copyright> <ttl>15</ttl> <image> <url><?php echo esc_url( get_theme_mod( LOGO_IMAGE_URL ) ); ?></url> <title><?php echo bloginfo('name'); ?></title> <link><?php echo site_url(); ?></link> </image> <?php /** * Fires at the end of the RSS2 Feed Header. * * @since 2.0.0 */ do_action( 'rss2_head'); while( have_posts()) : the_post(); ?> <item> <title><?php the_title_rss() ?></title> <link><?php the_permalink_rss() ?></link> <?php if ( get_comments_number() || comments_open() ) : ?> <comments><?php comments_link_feed(); ?></comments> <?php endif; ?> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> <?php $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id, 'full'); ?> <?php if(!empty($thumb_url[0])){ ?> <media:thumbnail url="<?php echo $thumb_url[0] ?>" /> <snf:analytics><![CDATA[<script><!-- Analytics埋め込み --></script>]]></snf:analytics> <?php } ?> <?php the_category_rss('rss2') ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <?php if (get_option('rss_use_excerpt')) : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php else : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php $content = get_the_content_feed('rss2'); ?> <?php if ( strlen( $content ) > 0 ) : ?> <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded> <?php else : ?> <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded> <?php endif; ?> <?php endif; ?> <?php if ( get_comments_number() || comments_open() ) : ?> <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss> <slash:comments><?php echo get_comments_number(); ?></slash:comments> <?php $cat_data = get_the_category(); $cat_list = get_category($cat_data); $query = new WP_Query( array( 'cat' => $cat_list->cat_ID, 'post__not_in' => array($post->ID), 'posts_per_page' => '1', 'offset' => '1', 'post_type' => 'post', 'orderby' => 'rand' )); while($query->have_posts()):$query->the_post(); $rel_thumb_id = get_post_thumbnail_id(); $rel_thumb_url = wp_get_attachment_image_src($rel_thumb_id, 'full'); ?> <snf:relatedLink title="<?php echo the_title_attribute(); ?>" link="<?php the_permalink(); ?>" thumbnail="<?php echo $rel_thumb_url[0]; ?>" /> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?> <?php rss_enclosure(); ?> <?php /** * Fires at the end of each RSS2 feed item. * * @since 2.0.0 */ do_action( 'rss2_item' ); ?> </item> <?php endwhile; ?> </channel> </rss>
↑ ↑ ↑
こういったPHPになっています。
2ページ目以降
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/2/
3ページ
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/3/
4ページ
https://ドメイン.com/%year%/%monthnum%/%day%/%postname%/4/
上記の様にディレクトリの最後に数字が増えていく状態になっております。
---------------------追加です!!!---------------------
https://soysauce-mg.com
運用しているサイトはこちらです。
https://soysauce-mg.com/2018/10/11/doikouza002/
サイト内の記事は
wordpress内のテキストで
を使用して次のページに切り替わる設定にしています。
回答1件
あなたの回答
tips
プレビュー