Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Easy.

    function do_feed_myfeed($for_comments) {
    // do whatever is needed to produce a feed here...
    // Basically, like what is done in feed-rss2.php or feed-atom.php
    }
    add_action('do_feed_myfeed', 'do_feed_myfeed', 10, 1);

    Make something like that into a plugin. If you make it load a separate template file like that, you should use the load_template() function to load that template file, like so:
    load_template(ABSPATH.PLUGINDIR.'/your-plugin-name/myfeed.php');

    Thread Starter shua

    (@shua)

    Thx, but I think Ill take the road less traveled.

    PS – when do you think the codex will be updated with 2.5 feed information?

    Thread Starter shua

    (@shua)

    Thread Starter shua

    (@shua)

    Otto,
    This is how I have been using feeds prior to 2.5:

    in wp-feed.php

    <?php
    
    if (empty($doing_rss)) {
        $doing_rss = 1;
        require(dirname(__FILE__) . '/wp-blog-header.php');
    }
    
    // Remove the pad, if present.
    $feed = preg_replace('/^_+/', '', $feed);
    
    if ($feed == '' || $feed == 'feed') {
        $feed = 'rss2';
    }
    
    if ( is_single() || ($withcomments == 1) ) {
        require(ABSPATH . 'wp-commentsrss2.php');
    } else {
        switch ($feed) {
        case 'atom':
            require(ABSPATH . 'wp-atom.php');
            break;
        case 'rdf':
            require(ABSPATH . 'wp-rdf.php');
            break;
        case 'rss':
            require(ABSPATH . 'wp-rss.php');
            break;
        case 'rss2':
            require(ABSPATH . 'wp-rss2.php');
            break;
        case 'comments-rss2':
            require(ABSPATH . 'wp-commentsrss2.php');
            break;
        case 'overview':
            require(ABSPATH . 'ssn-overview.php');
            break;
        case 'audience':
            require(ABSPATH . 'ssn-audience.php');
            break;
        case 'screens':
            require(ABSPATH . 'ssn-screens.php');
            break;
        case 'creative':
            require(ABSPATH . 'ssn-creative.php');
            break;
        case 'lp_overview';
            require(ABSPATH . 'ssn-lp-overview.php');
            break;
        case 'lp_ditl';
            require(ABSPATH . 'ssn-lp-ditl.php');
            break;
        case 'lp_activities';
            require(ABSPATH . 'ssn-lp-activities.php');
            break;
        case 'lp_research';
            require(ABSPATH . 'ssn-lp-research.php');
            break;
        case 'shortDesc';
            require(ABSPATH . 'ssn-shortDesc.php');
            break;
        case 'eh_overview';
            require(ABSPATH . 'ssn-eh-overview.php');
            break;
        case 'vc_overview';
            require(ABSPATH . 'ssn-vc-overview.php');
            break;
        case 'lph_overview';
            require(ABSPATH . 'ssn-lph-overview.php');
            break;
        case 'lp_relatedVenues';
            require(ABSPATH . 'ssn-lp-relatedVenues.php');
            break;
        }
    }
    
    ?>

    I am not versed in creating a plugin. I have looked at the codex and at some example plugins, but just ‘dont get it’ yet.

    Here is what I am doing in 2.5 (functions.php):

    function do_feed() {
    	global $wp_query;
    
    	$feed = get_query_var( 'feed' );
    
    	// Remove the pad, if present.
    	$feed = preg_replace( '/^_+/', '', $feed );
    
    	if ( $feed == '' || $feed == 'feed' )
    		$feed = get_default_feed();
    
    	$hook = 'do_feed_' . $feed;
    	if ( !has_action($hook) ) {
    		$message = sprintf( __( 'ERROR: %s is not a valid feed template' ), wp_specialchars($feed));
    		wp_die($message);
    	}
    	do_action( $hook, $wp_query->is_comment_feed );
    }
    
    /* Begin SSN Feeds */
    function do_feed_audience() {
    	load_template( ABSPATH . WPINC . '/ssn-audience.php' );
    }
    /* End SSN Feeds */

    What I understand is that the url parameter is passed as a variable to the function call. so do_feed_audience should be called if the requested url is https://www.url.com/postOrPage/?feed=audience.

    What returns is “ERROR: audience is not a valid feed template”

    when I do this:

    $hook = 'do_feed_' . $feed;
    	if ( !has_action($hook) ) {
    		do_feed_audience();
    	}

    The feed is displayed correctly.

    Thoughts??

    This problem drove me crazy too… the issue is you need to put
    add_action(‘do_feed_myfeed’, ‘do_feed_myfeed’, 10, 1);
    under actions in default-filters.php

    Thankyou! I’ve been trying to figure this out for the last day or so.

    Also, surprisingly easy to put into a plugin. Much more update-proof than editing the core files. Thanks!

    Thread Starter shua

    (@shua)

    Kristarella,
    I would love to see your plugin to do this as I am plugin retarded!

    best,
    shua

    Otto,

    I don’t need a full customized feed, I just need to separate the Tags from Categories. It seems that WordPress puts them all in <Category>. Is there an easy way to do that, or do I need a new feed template?

    Thanks
    Steve

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Feed modification’ is closed to new replies.