Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress post – move ‘discuss’ link to ‘filed under’ area?


  • mattpeckham
    Member

    @mattpeckham

    Hi all,

    I’m successfully using bbPress post on my site, but I’m wondering if anyone’s had any luck getting it to post elsewhere in the frontal WP post itself. Currently it appends itself to the end of the post with the text ‘Discuss in forums’ with the counter, etc. What I’d like to do is get it up where the comments would normally be displayed. I plan to eventually excise the comments php call entirely, but since ‘filed under’ is one php call, and bbpress is another, I’m not sure how do accomplish what I’m after (or if it’s even possible).

    Any thoughts?

    My site

    Best wishes,

    Matt

Viewing 11 replies - 1 through 11 (of 11 total)
  • Not sure if it’s been achieved, but that total comments/forum/blogposts integration is most integrated people’s wet dream, I think.


    mattpeckham
    Member

    @mattpeckham

    I’m getting close! :) I just need that last little bit – totally an aesthetics thing too. Functionally I’m thrilled. WP and bbPress = da bomb.

    Matt, have you finished this. I’ve tried to do it myself but with no luck I always end up throwing a sql error. :(

    There are a few things you can do. This WP plugin will, using also the bbPress Post plugin, show replies from the appropriate thread in your forum under your newspost, plus links to the thread to reply to it. You can also transfer existing comments; you need to be careful to only do it once, but that can also be found in that thread. It hasn’t yet been successfully made so that you can reply to the forum from the wordpress part of the site, as far as I know, but I’m sure it’s possible and will be done.

    So it’s perhaps 2/3rds of the way there. :)

    Thanks fel64. I’m looking to do away with the wordpress comments completely, just shut them off. However the bbpress post plugin posts the “discus in forms(0)” link at the end of the post. I have a bar at the bottom of each post and would like to format it in there. I’ve opened bbpress_post.php and saw the output of the post gets thrown into 1 variable. I would like to call a function in my wordpress php files, for example index.php, that calls the function from bbpress_post.php to display the “discuss in form” link.

    Hope that makes sense, but after read the thread you linked I don’t think it’s quite what i’m looking for. I’ll read it again thought as I’m tired. :)

    Thanks again.

    That’s very simple; go to wp-admin > Options > Discussion and set it so comments are off. You can also modify your template by deleting all the code for comments.

    To get the ‘discuss in forums’ link, simply open your template file, and replace the <?php comments_popup_link('&nbsp;make a comment', '1 comment', '% comments','','comments off'); ?> or similar with this:

    <?php forumreplylink(); ?>

    That’ll give you what you want. Note that you’ll need to put felblogtotopicid() into a WP plugin, like so:

    <?php
    /*
    Plugin Name: HFFIB
    Plugin URI:
    Description: Helper function for integrating bbPress into your theme.
    Version: 0
    Author: fel64
    Author URI: http://www.loinhead.net/
    */

    function felblogtotopicid( $felpostID ) {
    global $table_prefix, $wpdb;
    $posts_table = $table_prefix . "bbpress_post_posts";
    $topic_id = $wpdb->get_var("SELECT topic_id FROM <code>$posts_table</code> WHERE <code>post_id</code> = $felpostID LIMIT 1;");
    return $topic_id;
    }

    function forumreplylink() {
    //must be called from within the loop yadda yadda
    global $post;
    $rl = get_option( 'wpbb_path' ) . '/topic.php?id=';
    $tid = felblogtotopicid( $post->ID );
    echo '<a href="' . $rl . $tid . '">Reply!</a>' . "n";
    }
    ?>

    If you do that, you have to take it out of the hack should you implement it.

    Thanks for the help, but my error is now:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LIMIT 1’ at line 1]

    SELECT topic_id FROM wp_bbpress_post_posts WHERE post_id = LIMIT 1;

    after the error it adds the reply function but with an empty id: IE: “http://www.website.com/topic.php?id=

    That’s strange, it works for me. At a guess the root of it is that $post doesn’t exist, or that $post->ID is nonexistant.

    Can you replace function forumreplylink() { ... } with:

    function forumreplylink() {
    //must be called from within the loop yadda yadda
    global $post;
    if( $post ) {
    $rl = get_option( 'wpbb_path' ) . '/topic.php?id=';
    $tid = felblogtotopicid( $post->ID );
    echo '<a href="' . $rl . $tid . '">Reply!</a>' . "n";
    } else {
    echo 'ouch!';
    }
    }

    If it outputs ouch we’ll know that a missing global $post is indeed the problem. You are using it inside The Loop, aren’t you?

    OK here’s my file

    <?php
    /*
    Plugin Name: HFFIB
    Plugin URI:
    Description: Helper function for integrating bbPress into your theme.
    Version: 0
    Author: fel64
    Author URI: http://www.loinhead.net/
    */

    function felblogtotopicid( $felpostID ) {
    global $table_prefix, $wpdb;
    $posts_table = $table_prefix . "bbpress_post_posts";
    $topic_id = $wpdb->get_var("SELECT topic_id FROM '$posts_table' WHERE 'post_id' = $felpostID LIMIT 1;");
    return $topic_id;
    }

    function forumreplylink() {
    //must be called from within the loop yadda yadda
    global $post;
    if( $post ) {
    $rl = get_option( 'wpbb_path' ) . '/topic.php?id=';
    $tid = felblogtotopicid( $post->ID );
    echo '<a href="' . $rl . $tid . '">Reply!</a>' . "n";
    } else {
    echo 'ouch!';
    }
    }
    ?>

    I am running a custom theme, but it’s called in the spot as the original wordpress comments were and those worked fine. Here’s how I’m calling the function:

    <div class="details">
    <a>"><?php comments_number('No Comments','1 comment','% comments'); ?></a>
    <span class="tool">Category: <?php the_category(', '); ?></span>
    <span class="tool"><?php akst_share_link(); ?></span>
    <span class="tool"><?php forumreplylink(); ?></span>
    </div>

    Still getting the error, and no ‘ouch’ anywhere… I do have bbpress_post plugin running, is it supposed to or does this replace it? I’m thinking it has to be running, I’m just trying to elimate a stupid easy mistake I’ve made. :)

    Ack, I’m sorry but the stupid easy mistake is mine. This will only work for blog posts which have a corresponding topic in bbPress, so for any blog posts you made before installing the bbPress Post plugin it won’t work. Should’ve thought about that before copying you the code. :(

    function forumreplylink() {
    //must be called from within the loop yadda yadda
    global $post;
    $rl = get_option( 'wpbb_path' ) . '/topic.php?id=';
    $tid = felblogtotopicid( $post->ID );
    if( $tid ) {
    echo '<a href="' . $rl . $tid . '">Reply!</a>' . "n";
    } else {
    comments_number('No Comments','1 comment','% comments');
    }
    }

    Replace the old forumreplylink() with this and it will either show the reply link or a link to the comments. If you only want it to show the reply link but no link to comments, just take that comments line out. :)

    fel64, I do appreciate your help. Thank you very much. I still could not get it to work properly without throwing that error.

    I’ve moved on and will revisit the subject later as bbpress continues to evolve.

    Thanks again mate!

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