Support » Plugin: Post Views Counter » monthly views?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author dFactory

    (@dfactory)

    THe set of functions to query monthly, daily and custom dates are yet to be developed. So for now the direct db query is your only option, sorry.

    what are differents type ?

    4 = total
    3 = monthly ?
    2 = weekly ?
    1 = daily ?

    Plugin Author dFactory

    (@dfactory)

    Almost:

    0 = daily
    1 = weekly
    2 = monthly
    3 = yearly
    4 = total

    We use numbers to limit the db storage.

    nice, thx 🙂

    Is it possible to show total views and today views on the same post?

    Plugin Author dFactory

    (@dfactory)

    Yes, if you’re using the latest release there’s a way to do this.

    This is not documented and exposed yet. But if you look into includes/query.php you’ll find that we’ve extended WP_Query with extra ‘views_query’ parameter. What that mean is that you can take any post/posts, call regular WP_Query class and provide the date for which get post views count.

    Example:

    // get views for given period
    $args = array(
    	'post_type'			=> array( 'post' ),
    	'posts_per_page'	=> -1,
    	'orderby'			=> 'post_views',
    	'suppress_filters'	=> false,
    	'views_query'		=> array(
    		'year'	=> 2015,
    		'month' => 11,
    		'day'	=> 18
    	)
    );
    
    $posts = get_posts( $args );

    Each post returned will include additional ‘post_views’ field that will be the count of views for the requested period.

    If you want to have the result for one post only, you may just add p => 1, where 1 is the ID of the post.

    Hope this helps.

    Regards,
    Bartosz
    dfactory team

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘monthly views?’ is closed to new replies.