Support » Plugin: Post Views Counter » Using with REST

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

    (@dfactory)

    Hey,

    You can do it like this using the WP builtin REST API and PVC custom endpoint:
    ../wp-json/post-views-counter/get-post-views/?id=133
    where id is the post ID you want to get the views count for.

    By default the required capability is ‘read_posts’ so only registered and logged in users are allowed to make that kind of API call. You can adjust that however using pvc_rest_api_get_post_views_check filter hook.

    For example this added to your theme or plugin will allow anyone to access the views:

    add_filter( 'pvc_rest_api_get_post_views_check', '__return_true' );

    Thread Starter Arya

    (@aryaink)

    Super. Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using with REST’ is closed to new replies.