getTotalPosts( )


Gets the total amount of published posts on the blog.

The getTotalPosts() function returns a Promise that resolves to the total amount of published posts on your blog's site.

You can use the language option to filter posts for a specified language.

Permissions
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about app permissions.
Method Declaration
Copy
function getTotalPosts(
  options: GetTotalPostsOptions,
): Promise<GetTotalPostsResponse>;
Method Parameters
optionsGetTotalPostsOptions

Language Options.

Returns
Return Type:Promise<GetTotalPostsResponse>
JavaScript
import { posts } from "wix-blog-backend"; export async function getTotalPostsFunction() { try { const result = await posts.getTotalPosts(); console.log("Retrieved Result:", result); return result; } catch (error) { console.log(error); } } /* Promise resolves to: * { * "total": 19 * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?