Forum Replies Created

Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter Nurbis

    (@nurbis)

    Hi
    Thanks for the answer. I changed the function yesterday but it seems to be still not working (when I’m comparing plugin page stats for 24hrs and custom page with daily_views).
    But I looked to the phpmyadmin to wp_postmeta and the column views_daily has correct data. So the post showing on my custom page as “the most viewed” has significantly less views (in the column) then the truly most viewed.
    So might this be some other problem with wordpress ? Like problem with caching or something ? Or am I still doing something wrong with the plugin ?

    EDIT: I tried to turn off database caching (from W3TC) but it didn’t help.

    • This reply was modified 7 years, 6 months ago by Nurbis.
    Thread Starter Nurbis

    (@nurbis)

    Hi

    Functions.php :

    add_action( 'pre_get_posts', 'change_posts_on_homepage' );
    /* Storing views of different time periods as meta keys */
    add_action( 'wpp_post_update_views', 'custom_wpp_update_postviews' );
    function custom_wpp_update_postviews($postid) {
    	// Accuracy:
    	//   10  = 1 in 10 visits will update view count. (Recommended for high traffic sites.)
    	//   30 = 30% of visits. (Medium traffic websites)
    	//   100 = Every visit. Creates many db write operations every request.
    	$accuracy = 30;
    	if ( function_exists('wpp_get_views') && (mt_rand(0,100) < $accuracy) ) {
    		// Remove or comment out lines that you won't be using!!
    		update_post_meta( $postid, 'views_total',   wpp_get_views( $postid )            );
    		update_post_meta( $postid, 'views_daily',   wpp_get_views( $postid, 'daily' )   );
    		update_post_meta( $postid, 'views_weekly',  wpp_get_views( $postid, 'weekly' )  );
    		update_post_meta( $postid, 'views_monthly', wpp_get_views( $postid, 'monthly' ) );
    	}
    }

    Custom_page.php

    <?php $query = new WP_Query( array( 'paged' => get_query_var('paged'), 'meta_key' => 'views_weekly', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) );
    										if ($query->have_posts()) : ?>
    								   		<?php while ($query->have_posts()) : $query->the_post(); ?>
    	  
    										<!-- post -->
    	
    										<!-- // post -->
    										
    								   		<?php endwhile;?>

    sidebar.php

    <?php
    	$args = array(
    		'limit' => 20,
    		'range' => 'weekly',
    		'stats_views' => 0,
    		'post_type' => 'post'
    	);
    	wpp_get_mostpopular( $args );
    ?> 
    • This reply was modified 7 years, 7 months ago by Nurbis.
    • This reply was modified 7 years, 7 months ago by Nurbis.
    Thread Starter Nurbis

    (@nurbis)

    Thanks for the quick reply ?? So option to set other taxonomy than category will be in next update ? ??

    Thread Starter Nurbis

    (@nurbis)

    Also my second question, we can now include posts that belong to the specified category, any chance we can set specified custom term ?

    Thanks

    Thread Starter Nurbis

    (@nurbis)

    Yes, thats what Im saying. I dont need any other views, what I need is that when there will be list of most views posts, all posts which are older than 7 days will be excluded from the list. I believe there must be a solution on wordpress for this but unfortunately Im not too good on that and php ?? Please can you help me ?

Viewing 5 replies - 16 through 20 (of 20 total)