Skip to content

What is the best way to get api (Populate Posts | most views) with wpgraphql and How to add " like " for Posts ? #2869

Discussion options

You must be logged in to vote

put the code below in your functions.php theme's file.
#1860 (reply in thread)

query postbyid{
  post(id: "cG9zdDoxODU=") {
    id
    slug
    viewCount
  }
}
mutation UpdatePostViews($input: UpdatePostViewInput!) {
  updatePostView(input: $input) {
    clientMutationId
    views
  }
}

the WPGraphQL playground:
{
"input": {
"clientMutationId": "test",
"slug": "slug",
"views": 5
}
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by AliNaraghiA
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant