Php 带有ACF Pro的Wordpress自定义RSS未在Apple News Publisher中显示

Php 带有ACF Pro的Wordpress自定义RSS未在Apple News Publisher中显示,php,wordpress,rss,Php,Wordpress,Rss,我在Wordpress中遇到了一个使用ACF Pro插件的自定义RSS源的问题。它可以在几个RSS阅读器中使用,比如Feedly,这很好,但我们无法让它显示在apple新闻发布应用程序中 该提要将进行验证 以下是url结构: 这是代码。 //Add to functions.php for custom feed add_action('init', 'customMagfeed'); function customMagfeed() { add_feed('magfeed'

我在Wordpress中遇到了一个使用ACF Pro插件的自定义RSS源的问题。它可以在几个RSS阅读器中使用,比如Feedly,这很好,但我们无法让它显示在apple新闻发布应用程序中

该提要将进行验证

以下是url结构:

这是代码。

//Add to functions.php for custom feed

add_action('init', 'customMagfeed');
function customMagfeed() {
        add_feed('magfeed', 'customMagFeedFunc');
}
function customMagFeedFunc() {
        get_template_part('rss', 'magfeed');
}

//RSS Feed code

header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
?>
<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/"
        <?php do_action('rss2_ns'); ?>>
<channel>
        <title><?php bloginfo_rss('name'); ?></title>
        <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>en-us</language>
        <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
        <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
        <?php do_action('rss2_head'); ?>
        <?php while(have_posts()) : the_post(); ?>

                <item>
                        <title><?php the_title_rss(); ?></title>
                        <link><?php the_permalink_rss(); ?></link>
                        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
                        <dc:creator><?php the_author(); ?></dc:creator>
                        <guid isPermaLink="false"><?php the_guid(); ?></guid>
                        <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
                                                <content:encoded><![CDATA[<?php $authors = get_field('authors');
                            $photographers = get_field('photographers');
                            $article_share_image_obj = get_field('poster_image');
                            $article_share_image = $article_share_image_obj['url'];
                            if ($article_share_image_obj) :
                              echo '<img src="'.$article_share_image.'"/><br>';
                            endif;
                            if ($authors) :
                                            echo '<span>Written by ';
                                            $i = 0;
                                            foreach ($authors as $post) {
                                                $i++;
                                                if ($i === count($authors)) {
                                                    echo '<a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>';
                                                } else {
                                                    echo '<a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a> &amp; ';
                                                }
                                            }
                                            wp_reset_postdata();
                                            echo '</span><br>';
                                        endif;
                            if ($photographers) :
                                            echo '<span class="photographer-byline">Photography by ';
                                            $i = 0;
                                            foreach ($photographers as $post) {
                                                $i++;
                                                if ($i === (count($photographers))) {
                                                    echo '<a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>';
                                                } else {
                                                    echo '<a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a> &amp; ';
                                                }
                                            }
                                            wp_reset_postdata();
                                            echo '</span><br><br>';
                                        endif;
                                if (have_rows('article_content')) :
                                    while (have_rows('article_content')) : the_row();
                                        if (get_row_layout() == 'lead_text') :

                                //Lead Text start
                                              the_sub_field('text');
                                //Lead text start

                                        elseif (get_row_layout() == 'column_content') :

                                //Column content start
                                    $sidebar = get_sub_field('sidebar');
                                    if ($sidebar === 'sidebar-on-left') :
                                        if (have_rows('left_sidebar')) : while (have_rows('left_sidebar')) : the_row();
                                      //Sidebar builder
                                      $layout = get_row_layout();
                                        if ($layout === 'image') :
                                                $image = get_sub_field('image');
                                                $image_url = $image['sizes']['thumbnail-size'];
                                                $image_url_zoom = $image['sizes']['sidebar-size'];
                                                $caption = get_sub_field('caption');
                                                echo '<a href="'.$image_url_zoom.'" title="'.$caption.'">';
                                                echo '<img src="'.$image_url.'" alt="'.$caption.'"/></a>';
                                                echo $caption;
                                        endif;
                                      //End Sidebar Builder
                                        endwhile; endif;
                                        the_sub_field('content');
                                    elseif ($sidebar === 'sidebar-on-right') :
                                        the_sub_field('content');
                                        if (have_rows('right_sidebar')) : while (have_rows('right_sidebar')) : the_row();
                                      ///Sidebar builder
                                      $layout = get_row_layout();
                                        if ($layout === 'image') :
                                                $image = get_sub_field('image');
                                                $image_url = $image['sizes']['thumbnail-size'];
                                                $image_url_zoom = $image['sizes']['sidebar-size'];
                                                $caption = get_sub_field('caption');
                                                echo '<a href="'.$image_url_zoom.'" class="sidebar-image-wrap fancybox" title="'.$caption.'">';
                                                echo '<img src="'.$image_url.'" alt="'.$caption.'"/></a>';
                                                echo $caption;
                                        endif;
                                      //End Sidebar Builder
                                        endwhile; endif;
                                    elseif ($sidebar === 'sidebar-both') :
                                        if (have_rows('left_sidebar')) : while (have_rows('left_sidebar')) : the_row();
                                      //Sidebar builder
                                      $layout = get_row_layout();
                                        if ($layout === 'image') :
                                                $image = get_sub_field('image');
                                                $image_url = $image['sizes']['thumbnail-size'];
                                                $image_url_zoom = $image['sizes']['sidebar-size'];
                                                $caption = get_sub_field('caption');
                                                echo '<a href="'.$image_url_zoom.'" class="sidebar-image-wrap fancybox" title="'.$caption.'">';
                                                echo '<img src="'.$image_url.'" alt="'.$caption.'"/></a>';
                                                echo $caption;
                                        endif;
                                      //End Sidebar Builder
                                        endwhile; endif;
                                          the_sub_field('content');
                                        if (have_rows('right_sidebar')) : while (have_rows('right_sidebar')) : the_row();
                                      //Sidebar builder
                                      $layout = get_row_layout();
                                        if ($layout === 'image') :
                                                $image = get_sub_field('image');
                                                $image_url = $image['sizes']['thumbnail-size'];
                                                $image_url_zoom = $image['sizes']['sidebar-size'];
                                                $caption = get_sub_field('caption');
                                                echo '<a href="'.$image_url_zoom.'" class="sidebar-image-wrap fancybox" title="'.$caption.'">';
                                                echo '<img src="'.$image_url.'" alt="'.$caption.'"/></a>';
                                                echo $caption;
                                        endif;
                                      //End Sidebar Builder
                                        endwhile; endif;
                                    else :
                                        the_sub_field('content');
                                    endif;
                                //Column content end

                                        elseif (get_row_layout() == 'wide_photo_gallery') :

                                //Wide Photo Gallery start
                                    if (have_rows('photos')) : while (have_rows('photos')) : the_row();
                                        $gallery_photo = get_sub_field('photo');
                                        $gallery_photo_caption = $gallery_photo['caption'];
                                        $gallery_photo_url = $gallery_photo['sizes']['gallery-wide-large'];
                                        echo '<img src="'.$gallery_photo_url.'"/>';
                                    endwhile; endif;
                                //Wide Photo Gallery end

                                        elseif (get_row_layout() == 'photo_grid_builder') :

                                //Photo Grid builder start
                                  if (have_rows('photos')) : while (have_rows('photos')) : the_row();
                                     $photo_size = get_sub_field('photo_size');
                                     if ($photo_size === 'break') :
                                     else :
                                          $photo = get_sub_field('photo');
                                        $photo_url = $photo['url'];
                                            echo '<img src="'.$photo_url.'" class="background"/>';
                                             if (get_sub_field('photo_subtitle') || get_sub_field('photo_caption')) :
                                                         if (get_sub_field('photo_subtitle')) :
                                                             the_sub_field('photo_subtitle');
                                                         endif;
                                                         if (get_sub_field('photo_caption')) :
                                                                the_sub_field('photo_subtitle');
                                                             if (get_sub_field('photo_link')) {
                                                   echo '<a href="'.get_sub_field('photo_link').'">Photo Link</a>';
                                                 }
                                                         endif;
                                             endif;
                                      endif;
                                   endwhile; endif;
                                //Photo Grid builder end

                                        elseif (get_row_layout() == 'blockquote') :

                                //Blockquote start
                                    the_sub_field('quote_text');
                                            if (get_sub_field('quote_author')) :
                                                the_sub_field('quote_author');
                                            endif;
                                //Blockquote end

                                        elseif (get_row_layout() == 'video') :

                                //Video start
                                    $video_poster_obj = get_sub_field('poster_image');
                                    $video_poster_url = $video_poster_obj['sizes']['background-image-size'];
                                    echo '<a href="'.get_sub_field('video_url').'">Click here to watch the video</a><br>';
                                    echo the_sub_field('video_title').'<br>';
                                    echo the_sub_field('video_caption').'<br>';
                                //Video end

                                        elseif (get_row_layout() == 'layered_photo_gallery') :

                                //Layered gallery start
                                    $bg_img_obj = get_sub_field('background_image');
                                    $bg_img_url = $bg_img_obj['url'];
                                    if (get_sub_field('element_title') != '') {
                                            get_sub_field('element_title');
                                    }
                                    if (get_sub_field('element_description') != '') {
                                            get_sub_field('element_description');
                                    }
                                    if (have_rows('slides')) : while (have_rows('slides')) : the_row();
                                            $gallery_photo = get_sub_field('image');
                                            $gallery_photo_url = $gallery_photo['sizes']['gallery-wide-large'];
                                        echo '<img src="'.$gallery_photo_url.'"/>';
                                            if (get_sub_field('slide_title')) {
                                                get_sub_field('slide_title');
                                            }
                                            if (get_sub_field('slide_description')) {
                                                get_sub_field('slide_description');
                                            }
                                    endwhile; endif;
                                //Layered gallery end

                                        endif;
                                    endwhile;
                                endif; ?>]]></content:encoded>
                        <?php rss_enclosure(); ?>
                        <?php do_action('rss2_item'); ?>
                </item>
        <?php endwhile; ?>
</channel>
</rss>
//为自定义提要添加到functions.php
添加_操作('init','customMagfeed');
函数customMagfeed(){
添加_feed('magfeed','customMagFeedFunc');
}
函数customMagFeedFunc(){
获取模板部分(“rss”、“magfeed”);
}
//RSS源代码
标题('Content-Type:'。提要内容类型('rss-http');字符集='。获取选项('blog\u字符集'),true);
回声';
?>
';
}否则{
回音“&;”;
}
}
wp_reset_postdata();
回声“
”; endif; 如果(摄影师): 回声“摄影者”; $i=0; foreach(摄影师为$post){ $i++; 如果($i==(计数($摄影师))){ 回声'; }否则{ 回音“&;”; } } wp_reset_postdata(); 回音“

”; endif; 如果(有行(“文章内容”): while(have_rows('article_content')):the_row(); 如果(获取行布局()='lead\u text'): //引导文本开始 _sub_字段(“文本”); //引导文本开始 elseif(获取行布局()='column\u content'): //列内容开始 $sidebar=获取子字段(“sidebar”); 如果($sidebar=='sidebar on left'): if(have_rows('left_sidebar')):while(have_rows('left_sidebar')):the_row(); //边栏生成器 $layout=get_row_layout(); 如果($layout=='image'): $image=get_sub_字段('image'); $image_url=$image['size']['thumbnail-size']; $image\u url\u zoom=$image['size']['sidebar-size']; $caption=get_sub_字段(“caption”); 回声'; 回声$字幕; endif; //端边栏生成器 结束时;endif; _sub_字段(“内容”); elseif($sidebar==='sidebar on right'): _sub_字段(“内容”); if(have_rows('right_sidebar')):while(have_rows('right_sidebar')):the_row(); ///边栏生成器 $layout=get_row_layout(); 如果($layout=='image'): $image=get_sub_字段('image'); $image_url=$image['size']['thumbnail-size']; $image\u url\u zoom=$image['size']['sidebar-size']; $caption=get_sub_字段(“caption”); 回声'; 回声$字幕; endif; //端边栏生成器 结束时;endif; elseif($sidebar==='sidebar both'): if(have_rows('left_sidebar')):while(have_rows('left_sidebar')):the_row(); //边栏生成器 $layout=get_row_layout(); 如果($layout=='image'): $image=get_sub_字段('image'); $image_url=$image['size']['thumbnail-size']; $image\u url\u zoom=$image['size']['sidebar-size']; $caption=get_sub_字段(“caption”); 回声'; 回声$字幕; endif; //端边栏生成器 结束时;endif; _sub_字段(“内容”); 如果有