Search.../

getPost( )

Gets the all the information associated with the current blog post.

Description

The getPost() function returns a Promise that is resolved when all of the information about the post shown on the PostPage is retrieved.

Syntax

function getPost(): Promise<BlogPost>

getPost Parameters

This function does not take any parameters.

Returns

Fulfilled - When the information associated with the current post has been retrieved.

Return Type:

Promise<BlogPost>
NAME
TYPE
DESCRIPTION
_id
string

Post ID.

title
string

Post title.

plainContent
string

Text of the post.

publishedDate
Date

Date the post was originally published.

viewCount
number

Number of times the post was viewed.

likeCount
number

Number of likes the post received.

commentCount
number

Number of comments the post received.

lastPublishedDate
Date

Date the post was most recently published.

coverImageDisplayed
boolean

Indicates whether the cover image is displayed in the post.

timeToRead
number

Estimated time in minutes required to read the post.

pinned
boolean

Indicates whether the post was pinned to the top of the blog feed.

featured
boolean

Indicates whether the post is set as featured in the post settings. Featured posts appear in custom blog feeds.

hashtags
Array<string>

List of all hashtags in the post.

coverImage
string

The post's cover image.

postPageUrl
string

Relative URL of the post page on your published site.

excerpt
string

A few lines of text that appear in the blog feed. Defined in Post Settings or default of first 160 characters of the post.

Was this helpful?

Get the current blog post's information

Copy Code
1$w('#myPostPage').getPost()
2 .then( (post) => {
3 let postTitle = post.title;
4 let postContent = post.plainContent;
5 let postImage = post.coverImage;
6 // see example post object below
7 } )
8 .catch( (error) => {
9 console.log(error);
10 } );
11
12/*
13 * Example post object:
14 *
15 * {
16 * "_id": "5ccfd8c7b423c208e841dbbd",
17 * "title": "My Blog Post",
18 * "plainContent": "When it comes to design, the Wix blog has everything you need to create beautiful posts that will grab your reader's attention. You can add whatever tags you want (#vacation #dream #summer) throughout your posts to reach more people.",
19 * "publishedDate": "2019-05-06T09:11:33.622Z",
20 * "viewCount": 37,
21 * "likeCount": 8,
22 * "commentCount": 3,
23 * "lastPublishedDate": "2019-05-08T11:54:26.214Z",
24 * "coverImageDisplayed": true,
25 * "timeToRead": 1,
26 * "pinned": "false",
27 * "featured": "true",
28 * "hashtags": [
29 * 0: "vacation",
30 * 1: "dream",
31 * 2: "summer"
32 * ],
33 * "coverImage": "wix:image://v1/22cf07_256ac11eaf6548e0b2bb2fc3ede561ff~mv2.png/466_363...",
34 * "postPageUrl: "/post/my-blog-post",
35 * "excerpt": "When it comes to design, the Wix blog has everything you need to create beautiful posts that will grab your reader's attention. You can add whatever tags you want..."
36 * }
37 */