Creating a function to add post views to a post if it is added to a category

I’m looking to create a wordpress function that adds +5 post_views_count whenever a new post is added to a specific wordpress category. So far the function I’m writing looks like this…

function addPostViews($postID){
$count_key = ‘post_views_count’;
$count = $count + 5;
update_post_meta($postID, $count_key, $count);
}

I know I will need

if ( in_category( ‘categorynamehere’ )) {
//
}

and maybe more, but I don’t even know where to start reading right now.. Has anyone ever written a similar function?

Read more here:: Creating a function to add post views to a post if it is added to a category

Leave a Reply

Your email address will not be published. Required fields are marked *