Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    When a feed is added, a corresponding rewrite rule is also added so WP can properly direct a request to the right template. You may have stale rewrite rules. Try visiting the permalinks settings screen. Doing so causes the rewrite rules to be regenerated.

    If you still have trouble, there’s already another rewrite rule in place that is hijacking the request before it ever gets to the right place. Having a file with .dms returned causes me to suspect an .htaccess rule or similar is taking control before a request even gets to WordPress. You could try renaming your feed so it does not correspond to this interfering rule.

    Thread Starter f3rdal

    (@f3rdal)

    Thank you for your response and for assisting me. I have updated the permalinks multiple times. The WordPress website is a sandbox and is actually not accessible from the internet but only within the VPN network. I am also located within the VPN network with my computer and can retrieve the normal RSS feed under these network conditions. Regarding the template, I want to double check and ask you again. I have placed the template for the second feed in the “template-parts” folder within the active theme. The functions.php refers to this template. Is this correct?

    Thread Starter f3rdal

    (@f3rdal)

    One thing just caught my attention during testing. If I change the name of the template (and the name in the functions.php), as you suggested, from “feed-feedname” to “rss-feedname” and then call it as follows?https://my-url/feed/feedname, I still get an empty file but this time without the .dms at the end.

    Thread Starter f3rdal

    (@f3rdal)

    I have now installed another and new wordpress sandbox that is not in the VPN network – so reachable from the outside. I get the following error message from the w3c-feed-validator:

    This feed does not validate.

    • Server returned HTTP Error 500: Internal Server Error [help]
    • line 1, column 0: Undefined root element: error [help]<error>

    In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.

    • “text/xml” media type is not specific enough [help]

    I do not know where the error is.

    Thats my rss-custom-feed-code:

    <?php
    /**
     * Template Name: Custom RSS Template - myfeed
     */
    $postCount = 5; // The number of posts to show in the feed
    $posts = query_posts('showposts=' . $postCount);
    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="https://purl.org/rss/1.0/modules/content/"
            xmlns:wfw="https://wellformedweb.org/CommentAPI/"
            xmlns:dc="https://purl.org/dc/elements/1.1/"
            xmlns:atom="https://www.w3.org/2005/Atom"
            xmlns:sy="https://purl.org/rss/1.0/modules/syndication/"
            xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
            <?php do_action('rss2_ns'); ?>>
    <channel>
            <title><?php bloginfo_rss('name'); ?> - Feed</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><?php echo get_option('rss_language'); ?></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 the_excerpt_rss() ?&>></content:encoded>
                            <?php rss_enclosure(); ?>
                            <?php do_action('rss2_item'); ?>
                    </item>
            <?php endwhile; ?>
    </channel>
    </rss>
    • This reply was modified 1 year, 9 months ago by f3rdal.
    Moderator bcworkz

    (@bcworkz)

    If you directly request a feed URL from within a VPN, a proper feed will return a XML response regardless of accessibility from outside. Of course being publicly accessible does mean you can use online tools to validate your feed.

    How are you actually loading the template from your feed callback? WP by default will not look in /template-parts/ for template files, it needs little help. For example:

    // include the /themes/theme-name/template-parts/rss-feedname.php template
    get_template_part('template-parts/rss','feedname');

    Getting a 500 response from a feed request most likely means a fatal PHP error was encountered. The blank page you were getting once the feed was renamed is probably the infamous PHP “white screen of death” we often see when a fatal error is encountered. To learn what the error is, check you error log. Or define WP_DEBUG as true so PHP can output error messages right on the page.

    Thread Starter f3rdal

    (@f3rdal)

    Thank you very much. It was a mixture of inattention and haste that led me again and again to the error. After you gave me the right hints, my custom feed is now working. Thank you very much and have a nice day.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create a second feed besides the main RSS feed’ is closed to new replies.