WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a multisite network on WP 3.3.1. I now need to get all popular posts from across this network (preferably based on the amount of views).

Is this possible, and how do I do that?

share|improve this question
up vote 2 down vote accepted

simple list all last post about the network, not the popular posts; for popular posts you must use an plugin or track via Google Analytics etc.

<ul class='postlist no-mp'>

$blogs = $wpdb->get_results( 
    "SELECT blog_id,path FROM {$wpdb->blogs} 
    WHERE blog_id != {$wpdb->blogid} 
    AND site_id = '{$wpdb->siteid}' 
    AND spam = '0' 
    AND deleted = '0' 
    AND archived = '0' 
    order by blog_id", ARRAY_A
if ( 0 < count( $blogs ) ) :
    foreach( $blogs as $blog ) : 
        switch_to_blog( $blog[ 'blog_id' ] );

        if ( get_theme_mod( 'show_in_home', 'on' ) !== 'on' ) {

        $description  = get_bloginfo( 'description' );
        $blog_details = get_blog_details( $blog[ 'blog_id' ] );
        <li class="no-mp">

            <h2 class="no-mp blog_title">
                <a href="<?php echo $blog_details->path ?>">
                    <?php echo  $blog_details->blogname; ?>

            <div class="blog_description">
                <?php echo $description; ?>

            query_posts( 'showposts=5' );
            if ( have_posts() ) :
                while( have_posts() ) :
                    <div class="blog_post">
                        <div class="post_title">
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        <div class="post_excerpt">
                            <?php the_excerpt(); ?>
                <?php endwhile; ?>
            <?php endif; 
<?php endforeach;?>
share|improve this answer
Thanks very much for your code! I only don´t understand why I would list all post instead of the popular ones? – Marja Feb 6 '12 at 14:37
but it is important, that you write, how you find the popular posts; its not an WP feature; it give different solutions via plugin or tracking tools and the result of this must you use in this example of code – bueltge Feb 6 '12 at 15:18
ok I understand it now. I just don´t know how to do this ;o) So if anybody can help (me) with this ... – Marja Feb 11 '12 at 16:27
Ok, so if I understand you correctly. Ican use a plugin like postviews to find the populair posts in a blog, and use those results in your code example? – Marja Mar 10 '12 at 10:26
Yes, right. Also Google Analytics or any statistic tool – bueltge Mar 13 '12 at 20:34

You could try using the techniques described here: http://www.artiss.co.uk/2011/07/using-google-analytics-data-to-show-popular-posts

It basically uses the functions provided by the Google Analytics Dashboard plugin to show the most popular post in your theme.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.