WordPress.org

Support

Support » Plugins and Hacks » Google Analytics Popular Posts » [Plugin: Google Analytics Popular Posts] Placing the function in just the right place

[Plugin: Google Analytics Popular Posts] Placing the function in just the right place

  • Hi there, awesome plugin. It works exactly like I wanted! I was hoping you could help with something.

    I’m currently using a theme by WooThemes which has its own built-in “Popular Posts” widget. You can see it on my site here: http://dispatchesfromafootballsofa.com
    The problem is that the theme’s built-in function determines popularity based on number of comments, but I want popularity to be based on number of page views like in the plugin you’ve written.

    Here is the function used by my theme in making the current Popular posts widget: http://pastebin.com/LZ6a7Ywj

    Do you know where or how I can call your function instead? I figured, logically, it would be as easy as pasting GoogleAnalyticsPopularPosts_view() into just the right spot. That would mean the least amount of code changes. What do you think?

    Thanks!

    http://wordpress.org/extend/plugins/google-analytics-popular-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author koichiyaima

    @koichi-nakatsu

    As a function woo_widget_tabs_popular() is called a GoogleAnalyticsPopularPosts_view(),
    like this:

    <?php
    }
    
    /*-----------------------------------------------------------------------------------*/
    /* WooTabs - Popular Posts */
    /*-----------------------------------------------------------------------------------*/
    if (!function_exists( 'woo_widget_tabs_popular')) {
    	function woo_widget_tabs_popular() {
    /*			//Comment starts here
    		global $post;
    
    		if ( $days ) {
    			global $popular_days;
    			$popular_days = $days;
    
    			// Register the filtering function
    			add_filter('posts_where', 'filter_where');
    		}
    
    		$popular = get_posts( array( 'suppress_filters' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'numberposts' => $posts) );
    		foreach($popular as $post) :
    			setup_postdata($post);
    */			//Comment ends here
    		GoogleAnalyticsPopularPosts_view(true); //Add for "Google Analytics Popular Posts"
    
    ?>
    	}
    }

    What do you think?

    I have this same problem, and I don’t understand your recommendation, koichiyaima. Can you please be specific? Here is the woothemes popular tab function (below. So where do you recommend we change it (because we are trying to keep the woo thumbnail images along side the GAPP output:

    <?php
    $pop_posts = get_option(‘woo_popular_posts’);
    if (empty($pop_posts) || $pop_posts < 1) $pop_posts = 5;
    $now = gmdate(“Y-m-d H:i:s”,time());
    $lastmonth = gmdate(“Y-m-d H:i:s”,gmmktime(date(“H”), date(“i”), date(“s”), date(“m”)-24,date(“d”),date(“Y”)));
    $popularposts = “SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS ‘stammy’ FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = ‘1’ AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = ‘publish’ AND post_date < ‘$now’ AND post_date > ‘$lastmonth’ AND comment_status = ‘open’ GROUP BY $wpdb->comments.comment_post_ID ORDER BY stammy DESC LIMIT “.$pop_posts;
    $posts = $wpdb->get_results($popularposts);
    $popular = ”;
    if($posts){
    foreach($posts as $post){
    $post_title = stripslashes($post->post_title);
    $guid = get_permalink($post->ID);
    ?>

  • <?php
    woo_get_image(‘image’,50,50,’thumbnail’,90,$post->ID,’src’,1,0,”,”,true,false,false);
    ?>
    ” rel=”nofollow” title=”<?php echo $post_title; ?>”><?php echo $post_title; ?>
    <div style=”clear:both”></div>
  • <?php
    }
    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Google Analytics Popular Posts] Placing the function in just the right place’ is closed to new replies.
Skip to toolbar