Skip to:
Content
Pages
Categories
Search
Top
Bottom

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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • n/m, I figured it out. $forum wasn’t a global variable like I thought it was, so I just called a function to tell me the forum id and it fixed it. I’ll post this as a plugin if anyone wants shortly.

    ardentfrost, maybe you can help me..? I’m using the bbPress Post (0.02) by mByte, and with his plugin.. I had made a forum for the blog posts to show up, however.. I would like to make the blog posts, stay ONLY IN the “Blog Article Discussions” forum..

    Instead of them showing up in the “Latest Discussions” part of the forums index page.. And just have ONLY the threads made in the forums, show in the “Latest Discussions” section of the forum.. Is there maybe something that could be done for this?

    I’m basically asking to exclude one of the forums, from the “Latest Discussions” section. Thanks in advanced.. :) ;)

    spencerp


    so1o
    Participant

    @so1o

    Spencer

    two ways..

    1) edit /index.php

    change line 12 to

    $topics = get_latest_topics(0,1,'x');

    where x is the forum id of the ‘Blog Article Discussions’ forum

    2) plugin

    create a file named my-own-blog-forum-filter.php plugin in the my-plugins directory.. or any name you want.. and have the following code in it

    <?php

    function my_frontpage_forum_filter($where) {

    $where .= " AND forum_id NOT IN ('x') ";

    }

    add_filter('get_latest_topics_where', 'my_frontpage_forum_filter');

    ?>

    again replace x with the forum id that you need

    so1o, you’re awesome! Thanks alot!

    In /index.php, made it like this:

    $topics = get_latest_topics(0,1,3,4,’2′);

    Now the ones from the “Blog Article Discussion” forum, are NOT showing in the “Latest Discussion” section.. :) ;) Thanks again!

    However.. when I did try that plugin option, it deleted ALL the threads, except for the Blog Article Discussion posts.. but, I think that’s because I used the wrong id for the forum.. lol..

    When hovering over the “Blog Article Discussion” forum, it shows as “3” being the “id”.. but, in the admin control panel.. I assigned “2” for it.. so, that’s what the problem was.. Anyway.. she’s working now! Thanks again!!

    spencerp


    so1o
    Participant

    @so1o

    cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar