Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi theophile76,

    Unfortunately no, it’s not possible. The plugin queries the data for the selected Time Range only. Pulling info from different Time Ranges might have a performance impact on your site.

    Thread Starter theophile76

    (@theophile76)

    Hello, thx for reply.
    I dont care about performance impact.
    i juste want to ever show total views. Should i intergrate a “total view code” anywhere ?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright then. However, the changes involved might not be trivial and I’m a bit exhausted now (it’s 12:37 am over here) so I’ll come back later with an answer.

    Thread Starter theophile76

    (@theophile76)

    Ok thx a lot

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, here’s what you need to do:

    1. Change your shortcode to [wpp range=weekly order_by=views stats_comments=0 thumbnail_height=98 stats_views=1 post_type=post] (this is to order the posts by weekly views).

    2. Open wordpress-popular-posts.php, and around line 1156 you’ll find this block of code:

    // views
    if ( $instance['stats_tag']['views'] ) {
    
    	if ($instance['order_by'] == 'avg') {
    		$views_text = sprintf(
    		_n('1 view per day', '%s views per day', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews, 2)
    		);
    	}
    	else {
    		$views_text = sprintf(
    		_n('1 view', '%s views', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews)
    		);
    	}
    
    	$stats .= ($stats == "") ? "<span class=\"wpp-views\">" . $views_text . "</span>" : " | <span class=\"wpp-views\">" . $views_text . "</span>";
    
    }

    3. Change it to:

    // views
    if ( $instance['stats_tag']['views'] ) {
    
    	$total_views = sprintf(
    	_n('1 view', '%s views', intval($pageviews), 'wordpress-popular-posts'),
    	number_format_i18n(wpp_get_views($p->id), 2)
    	);
    
    	if ($instance['order_by'] == 'avg') {
    		$views_text = sprintf(
    		_n('1 view per day this week', '%s views per day this week', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews, 2)
    		);
    	}
    	else {
    		$views_text = sprintf(
    		_n('1 view this week', '%s views this week', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews)
    		);
    	}
    
    	$stats .= ($stats == "") ? "<span class=\"wpp-views\">{$total_views} (" . $views_text . ")</span>" : " | <span class=\"wpp-views\">{$total_views} (" . $views_text . ")</span>";
    
    }

    4. Save changes.

    I have not tested this code, though. Let me know what happens.

    Thread Starter theophile76

    (@theophile76)

    Thx for replay.

    Resutl : it rank by weekly views but does not show total view

    Result exemple :

    First in list : 1,00 views (52 848 views this week)
    Second in list : 353,00 views (10 663 views this week)

    I don’t know what are “1,00 views” and “353,00 views”

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, please change this:

    $total_views = sprintf(
    	_n('1 view', '%s views', intval($pageviews), 'wordpress-popular-posts'),
    	number_format_i18n(wpp_get_views($p->id), 2)
    	);

    … into:

    $total = wpp_get_views($p->id);
    
    	$total_views = sprintf(
    	_n('1 view', '%s views', intval($total), 'wordpress-popular-posts'),
    	number_format_i18n(wpp_get_views($p->id), 2)
    	);
    Thread Starter theophile76

    (@theophile76)

    I get the same result

    Plugin Author Hector Cabrera

    (@hcabrera)

    Weird. Please, try this instead:

    $total = wpp_get_views($p->id);
    
    	$total_views = sprintf(
    	_n('1 view', '%s views', intval($total), 'wordpress-popular-posts'),
    	$total
    	);
    Thread Starter theophile76

    (@theophile76)

    I replaced

    // views
    if ( $instance['stats_tag']['views'] ) {
    
    	if ($instance['order_by'] == 'avg') {
    		$views_text = sprintf(
    		_n('1 view per day', '%s views per day', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews, 2)
    		);
    	}
    	else {
    		$views_text = sprintf(
    		_n('1 view', '%s views', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews)
    		);
    	}
    
    	$stats .= ($stats == "") ? "<span class=\"wpp-views\">" . $views_text . "</span>" : " | <span class=\"wpp-views\">" . $views_text . "</span>";
    
    }

    Into

    // views
    if ( $instance['stats_tag']['views'] ) {
    
    	$total = wpp_get_views($p->id);
    
    	$total_views = sprintf(
    	_n('1 view', '%s views', intval($total), 'wordpress-popular-posts'),
    	$total
    	);
    
    	if ($instance['order_by'] == 'avg') {
    		$views_text = sprintf(
    		_n('1 view per day this week', '%s views per day this week', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews, 2)
    		);
    	}
    	else {
    		$views_text = sprintf(
    		_n('1 view this week', '%s views this week', intval($pageviews), 'wordpress-popular-posts'),
    		number_format_i18n($pageviews)
    		);
    	}
    
    	$stats .= ($stats == "") ? "<span class=\"wpp-views\">{$total_views} (" . $views_text . ")</span>" : " | <span class=\"wpp-views\">{$total_views} (" . $views_text . ")</span>";
    
    }

    And same result again

    Plugin Author Hector Cabrera

    (@hcabrera)

    Ok, I’m shooting arrows in the dark here. In order to give you better assistance, I need access to your site so I can check what’s going on and/or test myself directly. Otherwise, I’m out of ideas.

    Thread Starter theophile76

    (@theophile76)

    Ok, so how to contact you personaly ? then i give you access, because I realy need this to be solved.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Please, contact me via hcabrerab at gmail with access details.

    Thread Starter theophile76

    (@theophile76)

    Ok thx, I contacted you ??

    Plugin Author Hector Cabrera

    (@hcabrera)

    Thanks, Theo! I already replied to your e-mail. Please let know if you need further help.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Show total views but range by "weekly views"’ is closed to new replies.