Forums

podpress - override # of posts in a specific feed (8 posts)

  1. geekfarmlife
    Member
    Posted 1 year ago #

    You can override some things about an individual feed in PodPress. But we need an "archive" feed with all of our podcasts in it. We have 5 years of shows, and we do have listeners who want to download all 5 years of them in their podcatchers.

    In WordPress 2, we hacked a script together to do this, but it no longer works with WordPress 3, and it wasn't the right way to do it anyway. PodPress seems like the logical place for this.

    I have found how to do it, but I'm not sure how to integrate this into PodPress. Here is what I found: http://codex.wordpress.org/Function_Reference/query_posts#Usage_Tips

    I don't want this in the main feed, but in an extra feed I created in PodPress with the slug 'archive.'

    Thanks for your help!

  2. ntm
    Member
    Posted 1 year ago #

    Hi,

    I needed to think about it a little bit and I agree that such a category filter for the podPress Feeds is a good idea. I will probably add such an element in one of the next versions.

    But until than you could use a little filter plugin:

    <?php
    Plugin Name: podPress filters
    Plugin URI:
    Description: makes that a certain additional Feed contains only posts of one category
    Author:
    Version: 1.0
    Author URI:
    */
    
    add_action( 'pre_get_posts', 'get_only_posts_of_one_category' );
    function get_only_posts_of_one_category( $query ) {
    	if ( $query->is_feed ) {
    		$feedslug = $query->query_vars['feed'];
    
    		// change the slug name (in this example 'archive') of the Feed here:
    		if ( 'archive' === $feedslug ) {
    			// set in the slug name of the category here:
    			$query->query_vars['category_name'] = 'podcast';
    			// for posts of more than one category use category IDs instead e.g.:
    			// $query->query_vars['category__in'] = array(4, 10);
    		}
    	}
    }
    ?>

    Copy this code and paste it via a text editor software into a .php file (e.g. myfeedfilter.php). Store that .php file in the plugins folder of your blog and activate it via the plugins page of your blog (e.g. /wp-content/plugins/myfeedfilter/myfeedfilter.php).

    This filter plugin works together with the file type filter of the recent podPress versions.

    Regards,
    Tim

  3. ntm
    Member
    Posted 1 year ago #

    I have uploaded some more modification to the repository. Now, the current Development Version (8.8.9 beta 1) includes besides other changes category filters for the podPress Feeds.

    I would appreciate it very much if you would have the time to test this Development Version.

  4. geekfarmlife
    Member
    Posted 1 year ago #

    I do see the category filters in the new version, but it does not include any option to override the number of items in one of the feeds. Again, we want to have 20 posts in our default feed, but all posts (almost 300 at this point) in our Archive feed. I will look at the code snippet you pasted above to see if it does this.

  5. geekfarmlife
    Member
    Posted 1 year ago #

    I modified your code and got it to work! Here is what I came up with:

    <?php
    /*
    Plugin Name: podPress filters
    Plugin URI:
    Description: Overrides number of posts in the Archive feed
    Author: Misty Stanley-Jones
    Version: 1.0
    Author URI: http://geekfarmlife.com
    */
    
    add_action( 'pre_get_posts', 'get_only_posts_of_one_category' );
    function get_only_posts_of_one_category( $query ) {
            if ( $query->is_feed ) {
                    $feedslug = $query->query_vars['feed'];
    
                    // change the slug name (in this example 'archive') of the Feed here:
                    if ( 'archive' === $feedslug ) {
                            // set in the slug name of the category here:
                            add_filter('post_limits','no_limits_for_feed');
                                    function no_limits_for_feed($limits) {
                                       return ('') ;
                                    }
                    }
            }
    }
    ?>
  6. ntm
    Member
    Posted 1 year ago #

    we want to have 20 posts in our default feed, but all posts (almost 300 at this point) in our Archive feed.

    That was not clear for me after reading your first post. Further my mini plugin was not designed to regulate the number of posts in a certain feed. It was meant to have only posts of a certain category in a feed and that is what it does. But maybe I have not explained that enough.

    I have misunderstood your first post. But i think an option to regulate the number of posts in one of the podPress Feeds would be a good addition to the existing options.

    Regards,
    Tim

  7. geekfarmlife
    Member
    Posted 1 year ago #

    The code I pasted above does exactly what we want. So you can feel free to implement that in podPress if you want. Ideally, it would be good to have two choices: # of posts in the feed, or all posts.

    We also thought of a different way to do it, which would be something like including all posts that are not included in the main feed, plus an additional post at the top telling people "You've caught up. Please change your subscription to the regular feed."

    Another option would be the ability to have archive feeds, which would span date ranges. In that way, we could have a feed for every year of the show. As listeners catch up, they can change their subscriptions.

    The end result is that we want people to be able to access all of our old episodes in iTunes (we have some very devoted listeners who come to the show and want to hear all 5 years of back-logs), but we also don't want to over-burden our web server by having to serve out an RSS feed of all 5 years of shows for people who DON'T need it.

  8. ntm
    Member
    Posted 1 year ago #

    That are good ideas and I will keep them in mind. I also understand the reason for the desire to have these Feeds of old episodes.

    I will probably add some options to regulate the number of posts in Feeds. The ability to add an special post to a Feed is a good idea too. It could also be used signal that the Feed URL will change.

    Thanks,
    Tim

Topic Closed

This topic has been closed to new replies.

About this Topic