that the totals view for the whole website i was thinking something like get total views per user and show user total views on their profile..
I am afraid that is complicated because the views are tied to a post and not the author. So the whole SQL query might be complex and inefficient
it’s not that complicated, but it is indeed a bit slow if you have many views..
dreamsoft yeah i used you code… it does work but not all profile.. i check one of the user that have a lot post and views it does not work. it work on my and others ..
https://wordpress.org/support/topic/get-total-number-of-views-for-an-author-on-author-page?replies=2
marking questions that you actually did not solve is not nice at all…why do you do this?
that code doesn’t work, I know.
I modified it a bit, so it will work on author.php pages
<?php
$author_id = $curauth->ID; // do stuff to get user ID
$current_author = get_query_var('author');
$author_posts= get_posts( 'author='.$current_author.'&posts_per_page=-1' );
$counter = 0; // needed to collect the total sum of views
foreach ( $author_posts as $post )
{
$views = absint( get_post_meta( $post->ID, 'views', true ) );
$counter += $views;
}
echo "<hr /><center><p>My posts made a total number of <strong>{$counter} views</strong> (updated live)</p>
</center>";
?>
it work on others but not on this user.. this user got an error code
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 35 bytes) in /home/deafpira/public_html/wp-includes/wp-db.php on line 1587
i like this i wish it work.. 🙂
well that is because your server doesn’t have enough memory to run the code. Increase the memory allowed, talk to your host. As the plugin author said, it is a bit inefficient and needs some resources.
4gb is not enough? i got the top server out of that server company..
the error says it tried to use 40 MB, but failed. so you need to increase the allowed memory per process
ok that new to me.. how do i increase that memory per process?
dreamsoft.. it work! the server fix it.. thanks man i owe you one!
http://www.deafpiratevideo.com/deafpiratevideo