> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: queryPostCountStats(options: QueryPostCountStatsOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> posts --> queryPostCountStats # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/posts/query-post-count-stats.md # Method Description: Retrieves the number of published posts per month within a specified time range. The `queryPostCountStats()` function returns a Promise that resolves to the number of posts per month within the specified time range. You can set the time range using the `rangeStart` and `months` properties. The time range always starts on the 1st day of the month set in `rangeStart` and includes the number of `months` following `rangeStart`. For example, if `rangeStart` is set to `'2022-03-13'` and `months` is set to `4`, the time range will be from `'2022-03-01'` until `'2022-06-30'`. The time range ends on the last day of the month. >**Note:** If there are no published posts in a specific month, that month is not included in the response. For example, let's say a blog has `0` posts dated in February 2022. If `rangeStart` is set to `'2022-01-01'` and `months` is set to `3`, the response includes `postCount` values for January and March, but not February. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get post count per month ```javascript import { posts } from 'wix-blog-backend'; export async function queryPostCountStatsFunction() { try { const result = await posts.queryPostCountStats(); const stats = result.stats; const firstMonthPostCount = result.stats[0].postCount; console.log('Retrieved Result:',result); return result; } catch (error) { console.error(error); }; } /* Promise resolves to: * { * "stats": [ * { * "periodStart": "2020-08-01T00:00:00.000Z", * "postCount": 1 * }, * { * "periodStart": "2021-03-01T00:00:00.000Z", * "postCount": 2 * }, * { * "periodStart": "2022-03-01T00:00:00.000Z", * "postCount": 9 * }, * { * "periodStart": "2022-04-01T00:00:00.000Z", * "postCount": 6 * }, * { * "periodStart": "2022-05-01T00:00:00.000Z", * "postCount": 1 * }, * { * "periodStart": "2022-06-01T00:00:00.000Z", * "postCount": 2 * }, * { * "periodStart": "2022-07-01T00:00:00.000Z", * "postCount": 5 * } * ] * } */ ``` ## Get post count per month (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { posts } from 'wix-blog-backend'; export const queryPostCountStatsFunction = webMethod(Permissions.Anyone, async () => { try { const result = await posts.queryPostCountStats(); const stats = result.stats; const firstMonthPostCount = result.stats[0].postCount; console.log('Retrieved Result:',result); return result; } catch (error) { console.error(error); }; }); /* Promise resolves to: * { * "stats": [ * { * "periodStart": "2020-08-01T00:00:00.000Z", * "postCount": 1 * }, * { * "periodStart": "2021-03-01T00:00:00.000Z", * "postCount": 2 * }, * { * "periodStart": "2022-03-01T00:00:00.000Z", * "postCount": 9 * }, * { * "periodStart": "2022-04-01T00:00:00.000Z", * "postCount": 6 * }, * { * "periodStart": "2022-05-01T00:00:00.000Z", * "postCount": 1 * }, * { * "periodStart": "2022-06-01T00:00:00.000Z", * "postCount": 2 * }, * { * "periodStart": "2022-07-01T00:00:00.000Z", * "postCount": 5 * } * ] * } */ ``` ## Get post count per month within a given time period ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { posts } from 'wix-blog-backend'; /* Sample options value: * { * rangeStart: new Date('2022-03-10'), * months: 4 * } */ export const queryPostCountStatsFunction = webMethod(Permissions.Anyone, async (options) => { try { const result = await posts.queryPostCountStats(options); const stats = result.stats; const firstMonthPostCount = result.stats[0].postCount; console.log('Retrieved Result:',result); return result; } catch (error) { console.error(error); }; }); /* Promise resolves to: * { * "stats": [ * { * "periodStart": "2022-03-01T00:00:00.000Z", * "postCount": 9 * }, * { * "periodStart": "2022-04-01T00:00:00.000Z", * "postCount": 6 * }, * { * "periodStart": "2022-05-01T00:00:00.000Z", * "postCount": 1 * }, * { * "periodStart": "2022-06-01T00:00:00.000Z", * "postCount": 2 * } * ] * } */ ``` ---