Gets a post by the provided slug.
The getPostBySlug()
function returns a Promise that resolves to a post whose slug matches the given slug.
The slug
is the end of a post's URL that refers to a specific post. For example, if a post's URL is https:/example.com/blog/post/my-post-slug
, the slug is my-post-slug
. The slug is case-sensitive, and is generally derived from the post title, unless specified otherwise.
function getPostBySlug(
slug: string,
options: GetPostBySlugOptions,
): Promise<GetPostBySlugResponse>;
Slug of the post to retrieve.
The end of a post's URL, for example, https:/example.com/blog/post/my-post-slug
. Case sensitive and generally based on the post title if not specified.
Options specifying which fields to return.
import { posts } from "@wix/blog";
async function getPostBySlug(slug, options) {
const response = await posts.getPostBySlug(slug, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.