Skip to content

Instantly share code, notes, and snippets.

@benklocek
Forked from ntwb/ntwb_bbpress_custom_views.php
Created November 23, 2015 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benklocek/fc72f4b8e6473583d046 to your computer and use it in GitHub Desktop.
Save benklocek/fc72f4b8e6473583d046 to your computer and use it in GitHub Desktop.
bbPress - Custom Views
<?php
/*
Plugin Name: bbPress - Custom Views
Plugin URI: https://gist.github.com/ntwb/8167699
Description: bbPress - bbPress - Custom Views
Version: 0.1
Author: Stephen Edgar - Netweb
Author URI: http://netweb.com.au
*/
/**
* Register these bbPress views:
* - Popular Topics
* - Unpopular Topics
* - Random Topic
* - Recently Closed
* - Tagged Test
* - All Topics
* - Open (Not Closed)
* - Random Single Topic
*
* @uses bbp_register_view() To register the view
*/
function ntwb_register_custom_views() {
bbp_register_view( 'popular-topics', __( 'Popular Topics' ), array( 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value_num' ), false );
bbp_register_view( 'unpopular-topics', __( 'Unpopular Topics' ), array( 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value_num', 'order' => 'asc' ), false );
bbp_register_view( 'random-topic', __( 'Random Topic' ), array( 'orderby' => 'rand' ), false );
bbp_register_view( 'closed', __( 'Recently Closed' ), array( 'post_status' => 'closed' ), false );
bbp_register_view( 'taggedtest', __( 'Tagged Test' ), array( 'topic-tag' => 'test' ) );
bbp_register_view( 'all-topics', __( 'All Topics' ), array( 'order' => 'DESC' ), false );
bbp_register_view( 'open', __( 'Open (Not Closed)' ), array( 'post_status' => 'publish' ), false );
bbp_register_view( 'random-single-topic', __( 'Random Single-Topic' ), array( 'orderby' => 'rand', 'posts_per_page' => '1', 'max_num_pages' => '1' ), false );
}
add_action( 'bbp_register_views', 'ntwb_register_custom_views' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment