• Resolved pdonner

    (@pdonner)


    Hi. Sorry if this is a FAQ. I would like to maintain a support forum for video phones on the WordPress platform. This is what I did to test the idea: https://gxv3175.latitude64.org/. I configure the RSS reader of the phone to read the following URL: https://gxv3175.latitude64.org/?feed=rss2.

    Unfortunately the output at that address is much too complicated for the reader software of the phone. It cannot accommodate with the complexities of the XML structure of that feed. I would need simple output according to the following boilerplate example borrowed from Wikipedia:

    <?xml version="1.0" encoding="UTF-8" ?>
    <rss version="2.0">
    <channel>
            <title>RSS Title</title>
            <description>This is an example of an RSS feed</description>
            <link>https://www.someexamplerssdomain.com/main.html</link>
            <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
            <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
            <ttl>1800</ttl>
    
            <item>
                    <title>Example entry</title>
                    <description>Here is some text containing an interesting description.</description>
                    <link>https://www.wikipedia.org/</link>
                    <guid>unique string per item</guid>
                    <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
            </item>
    
    </channel>
    </rss>

    Can someone help me to arrive there? Thanks in advance, ph

    [No bumping. If it’s that urgent, consider hiring someone.]

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

    (@bcworkz)

    You need to create your own feed template. Take a look at Customizing Feeds in the Codex

    Thread Starter pdonner

    (@pdonner)

    Thanks bcworkz for the very useful advice. The ‘Customizing Feeds’ page explained that I would need to “clear the default actions then take appropriate steps to call load_template”. “Feed templates are located in the /wp-includes/feed-{type}.php”. There I found the old feed-rss.php which seems to produce the kind of output I’m longing for.

    <item>
    	<title><?php the_title_rss() ?></title>
    	<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    	<link><?php the_permalink_rss() ?></link>
    	<?php do_action('rss_item'); ?>
    </item>

    So the template seems already to be there (although the CDATA decoration could still be a problem for the GXV3175 RSS reader). By applying the tutorial advice, I think that this is how the default actions could be replaced:

    remove_all_actions( 'do_feed_rss2' );
    add_action( 'do_feed_rss2', 'plain_old_rss_feed', 10, 1 );
    
    function plain_old_rss_feed( $for_comments ) {
        $rss_template = get_template_directory() . '/feeds/feed-rss.php';
        if( file_exists( $rss_template ) )
            load_template( $rss_template );
    }

    However, it seems to me that all that new machinery is already available in the installed WP files. In default-filters.php I found this line:

    add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 );

    So it seems that the action is already there. And in functions.php there is a ready-made function which is already integrated by that add_action call:

    function do_feed_rss() {
            load_template( ABSPATH . WPINC . '/feed-rss.php' );
    }

    So apparently all functionality is already there (minus the template file existence checking lines). But apparently these lines are never being called (or then they are deactivated somewhere along the road).

    Not being very familiar with WP template geography I still fail to see where the patch should be entered. Could you guide me to the relevant template.

    Moderator bcworkz

    (@bcworkz)

    I’m pretty weak on how feeds are processed, but just from what you have presented, you would incorporate your second code block into your theme’s functions.php or create a small plugin. (Fairly easy, see Writing a Plugin) This disables the default rss2 template and points to yours instead. Right now your code points to the old rss template. You can patch it if you need to and save it as a different file. Then point your code to your patched file.

    If the old rss works as is, then your code should work as is too. Alternately, you could reactivate the existing rss 0.92 snippets you reference by only using add_filter('default_feed',function(){return 'rss';}); in your theme or plugin. The other code block would then be superfluous. Syntax may be flawed, but you get the idea.

    Thread Starter pdonner

    (@pdonner)

    Not being at home in the PHP environment and WP, I decideded to walk the quick and dirty road by putting the second code block into functions.php and by pointing at a modified rss 0.92 template. There was a bit of file/function name magic, but I found my way in the en.

    Apparently I should learn how to write a plugin, since that would be a clean approach which maybe could survive an update of the template.

    Now I still have to modify the transformation from rss xml to html, but that’s quite another story. – Warm thanks to bcworkz!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to achieve plain old RSS’ is closed to new replies.