Support Forum
Hi. The URL for my forum feed for all posts is:
http://myplasticfreelife.com/f.....81d9ab816/
I would like to add this feed to a weekly newsletter template, and I'm wondering if there is a way to either add parameters to the URL to specify only posts written within the last 7 days (regardless of how many there are) or if there is a way to create a new feed that would only contain posts from the last 7 days. I figured out how to do it with my Wordpress feed. Is there a way to do it in Simple Press?
Thanks,
Beth Terry
If you know how to use standard WordPress style filters then yes - there is one defined for the WHERE clause of the query for the Simple:Press feed. This takes this form:
$where = apply_filters('sph_rss_where', $where, $feed);
The passed $where variable contains the WHERE clause that will be used by the query and the $feed variable contains the feed type (such as 'group', 'forum' or 'all' etc).
You can massage the $where content to add a post_date clause
YELLOW
SWORDFISH
|
Actually, I'm not a programmer. I'm good at finding the code solutions I need by Googling and searching help forums and then copying and pasting. So I need more help than a line of code because I don't know what to do with it.
How about if I tell you what I did in Wordpress, and you can tell me how I would do something similar in SimplePress -- not just the code but where to put it or what file to create and where.
To create my custom Wordpress feed showing only posts for the past 7 days, I created a new template called rss-last7days.php and put it in my theme folder. Then, right after :
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
I added:
<?php $mylimit=7 * 86400; //days * seconds per day $post_age = date('U') - get_post_time('U'); if ($post_age < $mylimit) { ?>
This was code that I found in a Wordpress forum. I am good at copying and pasting and sort of understanding what it is that the php is doing. But I'm not a programmer.
So, to use the code that you have provided above, do I need to create a new template? If so, where do I put it? Do I need to edit sp-feed.php? If so, won't my changes get overwritten by updates? What other steps do I need to take?
Thanks,
Beth
I think this should do it:
$where = apply_filters('sph_rss_where', $where, $feed); add_filter('sph_rss_where', 'feed_filter', 1, 2); function feed_filter($w, $f) { $w .= ' AND ' . SFPOSTS .'.post_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY) '; return $w; }
You want to put that in either spFunctions.php file of the Simple:Press theme you are using (in the /templates folder of the theme) - or - in the functions.php file of your WordPress theme.
If you choose the Sp theme route then remember - as always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/.....g-a-theme/)
Anyway - try this and see if this works for you.
YELLOW
SWORDFISH
|
1 Guest(s)