Reputation: 445
I am very new to WordPress plugin development.
I have been searching this for a quite a while now but I am currently creating a plugin and I need my plugin to start logging the amount of views a post has had. I already know what I want this part of to do however I am having trouble find out how to a php function for when a post is viewed by a visitor to my WordPress site.
Could someone please show me what the wordpress hook/event is to run a function on post view/load? I want to do this without the use of template as well.
Upvotes: 0
Views: 1871
Reputation: 617
you can use post meta for count the post view. when a user view post that is single.php file you can place your custom function on this file. which update post meta when a user view post.
Another way is that you hook you custom function which count and update post meta in the following filter hook
add_filter( 'the_content', 'my_the_content_filter' );
Upvotes: 0