Hi,
I would like to add sitewide function of plugin http://wpmudevorg.wordpress.com/project/Sitewide-Multi-Widget to the template manually. I have tried following:
<?php
function sitewide_recent_posts($args) {
global $wpdb;
$options = get_option('sitewide_recent_posts');
$tags_blog = get_site_option( '1' );
$new_id_post = (int) $_POST["ds_sitewide_output_widget-blog_id"];
$wpdb->hide_errors();
$found_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id = '$new_id_post' AND public='1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'" ); // blogname?
if($found_id)
{ $options['1'] = (int) $_POST["ds_sitewide_output_widget-blog_id"];
} else {
$options['1'] = get_site_option( '1' );
}
$wpdb->show_errors();
update_option('sitewide_recent_posts', $options);
$options = get_option('sitewide_recent_posts');
// These lines generate our output.
$featured_blogs = '1'; // Clone multiple panel outputs such as ...
// $featured_blogs = array($options['blog_id'],63);
if (!is_array($featured_blogs)) $featured_blogs= array($featured_blogs); // hiccup
foreach($featured_blogs as $featured_blog) {
switch_to_blog($featured_blog); // minimize use of switch_to blog/restore_current_blog hence several widgets in one multiwidget
$tag_name_variable = $options['tagname']; // return all matches to any tags seperated by a comma
$category_name_variable = $options['catname']; // assign the variable as current category
$number_variable = $options['limit']; // how many?
// http://codex.wordpress.org/Template_Tags/query_posts a zillion combos
$query_string = array(
'tag' => $tag_name_variable,
'category_name' => $category_name_variable,
'showposts' => $number_variable
);
$query = new WP_Query($query_string);
if ($query->have_posts()) :
echo '<ul style="margin-top:5px;">';
while ($query->have_posts()) : $query->the_post();
echo '<li class="ra-recent-posts">';
// whatever you can do to a loop, do it here
{
?>
<?php echo get_avatar( get_the_author_id(), '40', $default = 'http://blogatize.net/wp-content/themes/blogatize-chameleon/design/avatar.jpg' ); ?>
<?php }
{ ?>
" title="Permanent Link to <?php if ( get_the_title() ) the_title(); else the_ID(); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?>
<small>
<?php
}
echo '<span style="font-weight:normal;">';
the_time('M jS, Y');
echo '</span> by '; the_author();
echo '</small>';
endwhile;
echo '';
endif;
}
}
?>
<?php sitewide_recent_posts('','',''); ?>
When I have in footer function <?php wp_list_pages('title_li='); ?> of a blog I got pages of main blog. What should I fix?
Thanks.