Output number of WordPress posts remaining until a post milestone is reached
We can get the total number of posts from the X-WP-Total response header from the /wp-json/wp/v2/posts/ endpoint, e.g. using fetch() in Javascript or apiFetch from @wordpress/api-fetch module in a custom block. Since number of fetched posts doesn’t affect the X-WP-Total header, we can use posts_per_page as 1 and only get the post id field with … Read more