Post Views Count (Support caching plugins!)
Using with get_posts() (1 post)

  1. crdunst
    Posted 2 years ago #


    Your plugin seems to work great for normal pages/posts.

    I am using a custom post type for advertisements - they are non public posts, but I retrieve them using get_posts() to display around my site.

    Viewing the post in this way doesn't increment the view count, so I was looking for a way to manually increment the view count based on the post id. I can see you have some filters available that may do this, but I can't figure it out.

    My code is as follows:

    $args = array(
    	'post_type' => 'advert',
    	'posts_per_page' => 2,
    	'orderby' => 'rand',
    	'post_status' => 'publish'
    $posts = get_posts( $args );
    foreach ($posts as $post) :  setup_postdata($post);
    	// I'm displaying my advert here
    	// how do I manually increase the view count here?

    Do you have a quick pointer how I can write back to increment the counter?

    Thanks in advance


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Post Views Count (Support caching plugins!)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic