Forum Replies Created
-
In reply to: Add custom bbcode tags into BBcode lite
Edit, this seems to only apply when I use override posting restrictions from the admin-can-post-anything plugin.
In reply to: Add custom bbcode tags into BBcode liteEdit, this seems to only apply when I use override posting restrictions from the admin-can-post-anything plugin.
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.
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.
What errors does it give you?
What errors does it give you?
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.
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.
In reply to: Add custom bbcode tags into BBcode liteI 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.
In reply to: Add custom bbcode tags into BBcode liteI 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.
In reply to: Loop through categoriesI 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.
In reply to: Loop through categoriesI 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.