Is it possible to change the order of posts, so that the most recent appears at the top of the page, and the origional post at the bottom?
Cheers.
Is it possible to change the order of posts, so that the most recent appears at the top of the page, and the origional post at the bottom?
Cheers.
The easy way is to find get_thread( $topic_id, $page ) in /topic.php and change it to get_thread( $topic_id, $page, true ).
The better way is to use a plugin so that you aren't modifying any core files. (This is untested)
<?php
/*
Plugin Name: Reverse Post Order
Plugin URI: http://bbpress.org/forums/topic/76
*/
function reverse_post_order() {
global $topic_id, $page, $topic, $bb_current_user;
global $bb_db_override, $posts, $forum, $tags, $user_tags, $other_tags, $list_start;
$bb_db_override = true;
$posts = get_thread( $topic_id, $page );
$forum = get_forum ( $topic->forum_id );
$tags = get_topic_tags ( $topic_id );
if ( $bb_current_user && $tags ) {
$user_tags = get_user_tags ( $topic_id, $bb_current_user->ID );
$other_tags = get_other_tags ( $topic_id, $bb_current_user->ID );
} elseif ( is_array($tags) ) {
$user_tags = false;
$other_tags = get_public_tags( $topic_id );
} else {
$user_tags = false;
$other_tags = false;
}
$list_start = ($page - 1) * bb_get_option('page_topics') + 1;
post_author_cache($posts);
}
add_action( 'bb_topic.php_pre_db', 'reverse_post_order' );
?>
Thanks very much, I will have a go with this tonight!
worked for me, good stuff. thanks!
is there a way to change the text styling of the most recent topic line of the front page? in other words, i already have the posts sorted so the most recent is always on the top line i'd really like to always have that line be, say, in bold or in a different color. is that possible?
The first line of the first post? Or do you mean the first thread in the first thread listing?
Sure, just do something like this. <?php if( !$is_foist_topic ) { echo ' class="first-topic"'; $is_foist_topic = true; } ?>
The first time it checks it won't be true, so it echoes code to change the class of the HTML. Then it sets it to true, so the next times it will be true and it'll skip that.
You want the code to set the class of the tr I believe, so put it in the HTML for that. Play around.
I copied the above plugin text to my html editor, saved as reverse.php and uploaded it to /my-plugins and activated it - but nothing happened! Ideas? :/
As mdawaffe mentioned, it was untested. As well, there have been core changes since, so somebody would have to 'debug' that little plugin. Anyone notice anything off the cuff on why it doesn't work?
Trent
Hey Mods;
(Tried to install plugin, got fatal error, so tried code file edit...)
I just want one post to have reverse order, so I tried:
if ( !$bb_db_override ) :
if ($topicid == '54') {
$posts = get_thread( $topic_id, $page, true );
} else {
$posts = get_thread( $topic_id, $page );
}
$forum = get_forum ( $topic->forum_id );
$tags = bb_get_topic_tags ( $topic_id );
But it doesn't seem to recognize the topic id - it displays all posts normally? Am I assuming wrongly that the topic_id is the number after "/topic/##" in the thread url?
Can you see anything I'm doing wrong? How do I isolate a single post to be reverse order?
Thanks!
You must log in to post.