untested by this should work
//change topic order
add_filter('bbp_before_has_topics_parse_args', 'rew_topic_order_by_meta');
function rew_topic_order_by_meta ($args) {
$args['meta_key'] = 'put_meta_key_here' ;
$args['orderby'] = 'meta_value' ;
$args['order'] = 'DESC' ; //or ASC if needed
return $args ;
}
just put your meta_key where it says
I found this also:
function my_custom_display_topic_index_query () {
$args[‘orderby’] = ‘date’;
$args[‘order’] = ‘DESC’;
return $args;
}
add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );
You wrote that buttons for that would be complicated, but if I reload the page and use GET-parameters, this way, would this work:
function my_custom_display_topic_index_query () {
if($_GET[…]==…) $myOrder=’date’; elseif(…) //or switch – then used a select box)
if ($_GET[‘descAsc’]==…) $descAsc=’DESC’;
$args[‘orderby’] = $myOrder;
$args[‘order’] = $descAsc;
return $args;
}
add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );
Buttons or select box would be inside the template and it gets the current webaddress and add desired parameters. If I add also cookies, the change would not need to do every time.
Exactly I think this code:
function my_custom_display_topic_index_query () {
global $_GET;
if($_GET[‘myOrderBy’])$myOrderBy=$_GET[‘myOrderBy’];else $myOrderBy=’last_edited’;
if($_GET[‘myOrder’])$myOrder=$_GET[‘myOrder’];else $myOrder=’DESC’;
$args[‘orderby’] = $myOrderBy;
$args[‘order’] = $myOrder;
return $args;
}
add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );
function printSelections(){
global $_SERVER;
return ‘<div class=”queries”><form action=”https://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’].'”><table class=”querytable”><tr><td><select name=”myOrderBy”><option value=”post_modified”>Viimeisin muutos</option><option value=”post_date”>Luontipäivä</option><option value=”post_title”>Nimi/option><option value=”post_author”>Tekijä/option></select></td><td><input name=”myOrder” type=”radio” value=”DESC” />Laskeva</td><td><input name=”myOrder” type=”radio” value=”ASC” />Nouseva</td></tr></table></form>’;
}
add_shortcode( ‘printSelections’, ‘printSelections’ );
// Add do_shortcode(‘printSelections’); to loop-forums.php
<li class=”bbp-header”>
<ul class=”forum-titles”>
<li class=”bbp-forum-info”><?php _e( ‘Forum’, ‘bbpress’ ); ?><?php topPostLinksEcho(); ?>
<li class=”bbp-forum-topic-count”><?php _e( ‘Topics’, ‘bbpress’ ); ?>
<li class=”bbp-forum-reply-count”><?php bbp_show_lead_topic() ? _e( ‘Replies’, ‘bbpress’ ) : _e( ‘Posts’, ‘bbpress’ ); ?>
<li class=”bbp-forum-freshness”><?php _e( ‘Freshness’, ‘bbpress’ ); ?>
<?php do_shortcode(‘[printSelections]’); ?>
depends on how you define complicated – solutions are frequently only a few lines of code, but getting there takes the time 🙂