/**
* Add bbpress dropdown list of forums
*/
function prefix_bbpress_dropdown_forum_list() {
if( ( !$prefix_bbpress_dropdown_forum_list = get_transient( \'prefix_bbpress_dropdown_forum_list\' ) ) ) {
$query = new WP_Query( array(
\'post_type\' => bbp_get_forum_post_type(),
\'post_status\' => bbp_get_public_status_id(),
\'ignore_sticky_posts\' => true,
\'no_found_rows\' => true,
\'orderby\' => \'menu_order title\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1 //Set Unlimited number of posts
) );
// Bail if no posts
if ( ! $query->have_posts() ) {
return;
}
$prefix_bbpress_dropdown_forum_list = \'
<select id="select-theme" onChange="window.location.href=this.value">
<option value="#">\' .esc_html__( \'Select a theme\', \'theme-palace\' ). \'</option>\';
while ( $query->have_posts() ) {
$query->the_post();
$forum_permalink = bbp_get_forum_permalink( $query->post->ID );
$forum_title = bbp_get_forum_title( $query->post->ID );
$prefix_bbpress_dropdown_forum_list .= \'
<option value="\' . esc_url( $forum_permalink ) . \'">\' . $forum_title . \'</option>\';
}
$prefix_bbpress_dropdown_forum_list .= \'</select>\';
set_transient( \'prefix_bbpress_dropdown_forum_list\', $prefix_bbpress_dropdown_forum_list, 365 * DAY_IN_SECONDS );
}
echo $prefix_bbpress_dropdown_forum_list;
}