Skip to content

Instantly share code, notes, and snippets.

@Abromeit
Last active July 27, 2018 21:50
Show Gist options
  • Select an option

  • Save Abromeit/d0dac75f20c0825b3b4c032885cf3d6d to your computer and use it in GitHub Desktop.

Select an option

Save Abromeit/d0dac75f20c0825b3b4c032885cf3d6d to your computer and use it in GitHub Desktop.
## POSTS #################################################################################################
# list all posts, paginated
# where result posts might be everthing under '/news/' or sth.
#
# interesting values included:
# * comment_status (if comments are allowed)
# * ping_status (if pings from other weblogs are allowed)
# * slug
# * date_gmt
# * modified_gmt
# * link (the absolute post url)
# * content.rendered (AFAIS the full post content without boilerplate - perfect for crawlers)
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/posts?page=1&per_page=100
# list latest posts, paginated
# where result posts might be filtered from everthing under '/news/' or sth.
#
# `after` cannot be written as '2018-03-00'!
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/posts?after=2018-03-01T00:00:00&page=1&per_page=100
# search within posts (ala `?q=…`), paginated
# where result posts might be filtered from everthing under '/news/' or sth.
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/posts?search=online+marketing&page=1&per_page=100
## PAGES #################################################################################################
# list all pages, paginated
# where result pages might be 'about us', 'contact', etc.
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/pages?page=1&per_page=100
# search within pages (ala `?q=…`), paginated
# where result pages might be 'about us', 'contact', etc.
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/pages?search=online+marketing&page=1&per_page=100
## OTHER #################################################################################################
# list all wp users, paginated
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/users?page=1&per_page=100
# list all comments, paginated
#
# default `per_page` is 10
https://some-wordpress-website.tld/wp-json/wp/v2/comments?page=1&per_page=100
@Abromeit
Copy link
Author

get number/sum of comments on a blog

curl -sI 'https://seo-united.de/blog/wp-json/wp/v2/comments?page=1&per_page=1' | grep -oP '(?<=X-WP-Total: )\d+'
example result:
26142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment