Last active
August 29, 2015 14:04
-
-
Save ntwb/ca87b9b75a42215b2889 to your computer and use it in GitHub Desktop.
bbPress - Random Single Topic - http://bbpress.org/forums/topic/random-topic-link/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: bbPress - Random Single Topic | |
Plugin URI: https://gist.github.com/ntwb/ca87b9b75a42215b2889 | |
Description: bbPress - Random Single Topic | |
Version: 0.1 | |
Author: Stephen Edgar - Netweb | |
Author URI: http://netweb.com.au | |
*/ | |
// bbPress - Random Single Topic | |
function ntwb_bbpress_random_single_topic() { | |
if ( bbp_has_topics( array( 'orderby' => 'rand', 'posts_per_page' => 1 ) ) ) { | |
while ( bbp_topics() ) : bbp_the_topic(); | |
?> | |
<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>"><?php bbp_topic_title(); ?></a> | |
<?php | |
endwhile; | |
} | |
} | |
// Hook into action | |
add_action('bbp_template_before_lead_topic','ntwb_bbpress_random_single_topic'); | |
// Add it as a shortcode [ntwb-bbpress-random-single-topic] | |
add_shortcode('ntwb-bbpress-random-single-topic', 'ntwb_bbpress_random_single_topic'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment