Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi I have this plugin

http://pastebin.com/a7t1SPXj

which imports feeds from various websites. There are two problems I would like help in solving. The first is that I would like to place a limit on the date of the oldest feeds retrieved, limiting all results to the last 7 days. Secondly when I add more than 10 feeds it really starts to slow down the page and gets me PHP timeout errors. How can I make it more efficient, so it doesn't require huge load times on every page load? Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Instead of checking and updating the feeds every time you do the shortcode, instead register cron tasks for each feed timed to their update schedule. Also saving the feed items as posts, and storing the GUID in the posts meta, then only saving the feed items that are new, will simplify things. It will also let you use WP_Query on posts instead of dealing with feed transients too.

share|improve this answer
    
Could you explain why a WP_Query is more efficient than fetch_feed? fetch_feed uses get_transient which is a direct call to the database no query is run. –  Chris_O Mar 5 '12 at 11:46
    
Because it can speed up the feed aggregation stage. If you cache anything with transients, it should be the final output, not the aggregated feed items. Right now your transients are being used as your timing mechanism, but mobing to cron makes the process asynchronous, and lets you break the task up into smaller tasks for each feed. –  Tom J Nowell Mar 5 '12 at 14:15
    
Thanks, I sort of get it, but not sure I have enough knowledge to implement it. Are there any examples I can follow to implement this? –  drtanz Mar 5 '12 at 21:34
    
1  
no no, add a post meta containing the source URL, then search for posts with that meta equal to the URL when testing if it's new or not. If no posts are found it;s new. If a post is found with a meta containing the URL, it's not new –  Tom J Nowell Aug 23 '12 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.