Using with get_posts()
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? endforeach; wp_reset_query();
Do you have a quick pointer how I can write back to increment the counter?
Thanks in advance
- The topic ‘Using with get_posts()’ is closed to new replies.