thebreiflabb (@thebreiflabb)

Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)

  • thebreiflabb
    Member

    @thebreiflabb

    Edit, this seems to only apply when I use override posting restrictions from the admin-can-post-anything plugin.


    thebreiflabb
    Member

    @thebreiflabb

    Edit, this seems to only apply when I use override posting restrictions from the admin-can-post-anything plugin.


    thebreiflabb
    Member

    @thebreiflabb

    It works perfectly for me, though you can try with some debugging, for example try

    echo $counter;

    inside the foreach loop to see if you have any loop at all. Check the source code if you have anything there.


    thebreiflabb
    Member

    @thebreiflabb

    It works perfectly for me, though you can try with some debugging, for example try

    echo $counter;

    inside the foreach loop to see if you have any loop at all. Check the source code if you have anything there.


    thebreiflabb
    Member

    @thebreiflabb

    What errors does it give you?


    thebreiflabb
    Member

    @thebreiflabb

    What errors does it give you?


    thebreiflabb
    Member

    @thebreiflabb

    If your wordpress and bbpress share the same database you can simply edit sidebar.php

    On the top of the file add:

    <?php require_once(ABSPATH."/forum/bb-load.php"); ?>

    This will give you access to the bbpress functions. (Edit to the path of your bbpress installation)

    Then where you are going to output your latest posts add this:

    <?php
    global $wpdb;
    $query = "SELECT * FROM bbp_topics WHERE topic_status='0' ORDER BY topic_time DESC LIMIT 6";
    $topics = $wpdb->get_results($query);
    $counter = 0;
    ?>

    This will find the latest posts, I do it this way so it won’t show the same topic several times if many posts have been made in the same topic. Also edit bbp_ to your bbpress db prefix.

    Finally to output simply add something similar to this:

    <div id="latest-posts" class="border">
    <h2>Latest forum posts</h2>
    <?php foreach($topics as $topic) : ?>
    <div class="<?php echo $counter % 2 ? "gray" : "white"; ?>"><a href="<?php topic_last_post_link($topic->topic_id); ?>"><?php topic_title($post->topic_id); ?></a></div>
    <?php $counter++; ?>
    <?php endforeach; ?>
    </div>

    Edit to your preference on html and css.


    thebreiflabb
    Member

    @thebreiflabb

    If your wordpress and bbpress share the same database you can simply edit sidebar.php

    On the top of the file add:

    <?php require_once(ABSPATH."/forum/bb-load.php"); ?>

    This will give you access to the bbpress functions. (Edit to the path of your bbpress installation)

    Then where you are going to output your latest posts add this:

    <?php
    global $wpdb;
    $query = "SELECT * FROM bbp_topics WHERE topic_status='0' ORDER BY topic_time DESC LIMIT 6";
    $topics = $wpdb->get_results($query);
    $counter = 0;
    ?>

    This will find the latest posts, I do it this way so it won’t show the same topic several times if many posts have been made in the same topic. Also edit bbp_ to your bbpress db prefix.

    Finally to output simply add something similar to this:

    <div id="latest-posts" class="border">
    <h2>Latest forum posts</h2>
    <?php foreach($topics as $topic) : ?>
    <div class="<?php echo $counter % 2 ? "gray" : "white"; ?>"><a href="<?php topic_last_post_link($topic->topic_id); ?>"><?php topic_title($post->topic_id); ?></a></div>
    <?php $counter++; ?>
    <?php endforeach; ?>
    </div>

    Edit to your preference on html and css.


    thebreiflabb
    Member

    @thebreiflabb

    I made it work in a way using this:


    <?php
    /*
    Plugin Name: BBTexCode
    Description: [tex][/tex] to image
    Plugin URI:
    Author: Sondre Kjøniksen
    Version: 1.00
    */

    function bb_tex_replace( $text ) {
    $text = preg_replace('/[tex](.*?)[/tex]/ie', "'<img src="/cgi-bin/mathtex.cgi?'.rawurlencode('$1').'" align="middle" />'", $text);
    return $text;
    }
    add_filter('post_text', 'bb_tex_replace');
    ?>

    Though I still have a problem, it seems bbpress strips backslashes when adding the post to the DB. Is it possible to do so bbpress skips stripping backslashes from [tex][/tex] tags? At the moment it works if I write double backslashes like: [tex]\LaTeX \frac12[/tex] But it is kind of annyoing having to type double every time.


    thebreiflabb
    Member

    @thebreiflabb

    I made it work in a way using this:


    <?php
    /*
    Plugin Name: BBTexCode
    Description: [tex][/tex] to image
    Plugin URI:
    Author: Sondre Kjøniksen
    Version: 1.00
    */

    function bb_tex_replace( $text ) {
    $text = preg_replace('/[tex](.*?)[/tex]/ie', "'<img src="/cgi-bin/mathtex.cgi?'.rawurlencode('$1').'" align="middle" />'", $text);
    return $text;
    }
    add_filter('post_text', 'bb_tex_replace');
    ?>

    Though I still have a problem, it seems bbpress strips backslashes when adding the post to the DB. Is it possible to do so bbpress skips stripping backslashes from [tex][/tex] tags? At the moment it works if I write double backslashes like: [tex]\LaTeX \frac12[/tex] But it is kind of annyoing having to type double every time.


    thebreiflabb
    Member

    @thebreiflabb

    I figured out myself, added a counter to see if it is the first category, else the loop puts in a </div> before adding a new category, then after the loop adding a </div> to close the last one off.


    thebreiflabb
    Member

    @thebreiflabb

    I figured out myself, added a counter to see if it is the first category, else the loop puts in a </div> before adding a new category, then after the loop adding a </div> to close the last one off.

Viewing 12 replies - 1 through 12 (of 12 total)