Help with a plugin
-
I wanted a way to let the topics listed under “Latest Discussion” expire after a while (eg., no longer show up if there has been no activity after a week), so I wrote this little plugin which works alright, except it messes up the forums. Each forum, when clicked, shows all posts no matter what forum they’re in.
Any help would be appreciated. This is a simple script, I just copied the $where code from functions.php and added the filter, then added my “expire after 7 days” addition. Any help would be appreciated, I’m probably just not seeing something simple.
function get_where_plugin() {
$forum = (int) $forum;
$where = 'WHERE topic_status = 0';
if ( $forum )
$where .= " AND forum_id = $forum ";
if ( !empty( $exclude ) )
$where .= " AND forum_id NOT IN ('$exclude') ";
if ( is_front() )
$where .= " AND topic_sticky <> 2 AND SUBDATE(NOW(), INTERVAL 7 DAY) < topic_time "; // 2nd part is my addition
elseif ( is_forum() || is_view() )
$where .= " AND topic_sticky = 0 ";
return $where;
}
add_filter ( 'get_latest_topics_where', 'get_where_plugin' );
To see how it’s misbehaving, you can go to http://www.rayd.org/forums/ and just click on either forum (General Chat or New Forum Discussion) and see that both contain the same data. However, it’s working great on the front page.
- You must be logged in to reply to this topic.