Reply To: showing topics from separate sites – need formatting help
Update on this. It turns out my code was insufficient. If have fixed it, sort of, which has led to another problem. First, here is the updated code:
<?php
/*
Plugin Name: Recent bbpress Topics
Plugin URI: http://whosgotbooks.com/wp-content/plugins
Description: A plugin to display recent bbpress topics across the network
Version: 1.0.0
Author: Jerry Caldwell
Author URI: http://whosgotbooks.com
License: Open Source
*/
function recent_bbpress_topics_shortcode() {
recent_bbpress_topics(); }
add_shortcode( 'recent-bbpress-topics', 'recent_bbpress_topics_shortcode' );
//Add Recent Topics to BBPress
function recent_bbpress_topics() {
switch_to_blog(9);
if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 7 ) ) ) {
bbp_get_template_part( 'bbpress/loop', 'topics' );
}
// Hook into action
add_action('bbp_template_after_forums_loop','recent_bbpress_topics');
} ?>
Using the line “switch_to_blog(9);” works great to get the topics from site 9 to the main site. But now my problem is; it brings some unwanted behavior. The main content looks great, but the sidebars change to the format of site 9. Perhaps this has become a wordpress issue and not a bbpress issue? Perhaps I need to use code in addition to “switch_to_blog(9);” that prevents the unwanted behavior? If I need to change this to a wordpress thread, please let me know and I will. Otherwise, if you can provide a solution, that would be great.