Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Here’s what we did over at PixelTango.

    In functions.php:

    function popularPosts($num) {
        global $wpdb;
    	$mpQuery = "SELECT $wpdb->posts.ID, $wpdb->posts.post_name, $wpdb->posts.post_title, SUM(pageviews) AS pageviews FROM $wpdb->posts LEFT JOIN wp_popularpostsdatacache ON $wpdb->posts.ID = wp_popularpostsdatacache.id WHERE (day >= '" .gmdate("Y-m-d"). "' - INTERVAL 30 DAY) GROUP BY id ORDER BY pageviews DESC LIMIT " . $num . "";
    	$mostpopular = $wpdb->get_results($mpQuery);
        return $mostpopular;
    }

    And in our theme we use this with a regular wordpress loop like so:

    <ul class="sq-list">
        <?php $popular = popularPosts(16); foreach ($popular as $post) : setup_postdata($post); ?>
            <li><a title="<?php the_title(); ?>" href="<?php echo get_permalink($post->id); ?>"><?php the_post_thumbnail( 'post-tn-square', array( 'alt' => the_title( '', false, '' ), 'title' => the_title( '', false, '' ) ) ); ?></a></li>
        <?php endforeach; ?>
    </ul>

    Please note: I am in no way a good PHP-developer, so use this code with caution lol… Hopefully this is useful for someone!

    We are experiencing the same issue at PixelTango. Take a look at this screen-shot, where the bottom right thumbnail is not working properly.

    Here’s the code we use to output the images:
    wpp_get_mostpopular('limit=12&range=monthly&order_by=views&pages=0&thumbnail_selection=usergenerated&thumbnail_width=115&thumbnail_height=115&header_start="<h5><span>"&header_end="</span></h5>"&stats_comments=0&stats_views=0&do_pattern=1&pattern_form="{image}"');

    Any help or suggestions would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)