• Resolved David Gard

    (@duck_boy)


    Hi all,

    My company have a website and an intranet, both running WordPress. Both contain profiles of our staff, so to try and save having to update both sites, I’m looking for a way to get the RSS feed for one specifc post. I know you can get the Comments Feed, but that is no good to us as it is the content that we are after.

    Is there a way of doing this without having to grab all posts of that type in the feed and looping though them to find the correct one?

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter David Gard

    (@duck_boy)

    Ok, I found a way to do this on the website that returns the feed.

    This works by checking for a query var called ‘person’ in the feed URI. If there are any entruis, IDs for those posts all searched, and if they are found, only they are retruned. If person does not exist, I sinmply return my default feed (which actually contains only two custom post types).

    add_filter('request', 'feed_request');
    function feed_request($qv){
    
    	$rss_post_types = get_option('general_options');
    	$rss_post_types = $rss_post_types['post_types_for_rss'];
    
    	if(isset($qv['feed']) && !isset($qv['post_type']))
    
    		/** Only specific staff (by ID) have been requested */
    		if(isset($_GET['person'])) :
    
    			$persons = explode(',', $_GET['person']);
    			array_walk($persons, '_make_person_id_callback');
    
    			$qv['post_type'] = 'staff';
    			$qv['post__in'] = $persons;
    
    		/** The usual RSS feed has been requested */
    		else :
    
    			$qv['post_type'] = $rss_post_types;		
    
    		endif;
    
    	return $qv;
    
    }
    
    function _make_person_id_callback(&$value){
    
    	$value = get_post_id(trim($value));
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘RSS Feed for one specific post’ is closed to new replies.