> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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: listPosts(options: ListPostsOptions)

# Method package: wixBlogBackend

# Method menu location: wixBlogBackend --> posts --> listPosts

# Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/posts/list-posts.md

# Method Description:

Retrieves a list of published posts.


The `listPosts()` function returns a Promise that resolves to a list of up to 100 published posts.

Using the `options` parameter, you can filter your list of posts, set the amount of posts to be returned, and sort your list in a specified order.

By default, the list is sorted by `firstPublishedDate` in descending order, and the amount of posts returned is 50.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## List posts from a blog

```javascript
import { posts } from 'wix-blog-backend';

export async function listPostsFunction() {
  try {
    const result = await posts.listPosts();
    const firstPostTitle = result.posts[0].title;
    const firstPostExcerpt = result.posts[0].excerpt;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
}


/* Promise resolves to:
 * {
 *   "posts": [
 *     {
 *       "_id": "0a265609-e16e-4c96-b71a-2a62b513e6c8",
 *       "categoryIds": [],
 *       "commentingEnabled": true,
 *       "excerpt": "some text",
 *       "featured": false,
 *       "firstPublishedDate": "2022-05-25T13:56:19.023Z",
 *       "hashtags": [],
 *       "heroImage": ""
 *       "language": "en",
 *       "lastPublishedDate": "2022-05-25T13:56:19.023Z",
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea",
 *       "minutesToRead": 1,
 *       "pinned": false,
 *       "preview": false,
 *       "pricingPlanIds": [],
 *       "relatedPostIds": [],
 *       "slug": "_new-post",
 *       "tagIds": [],
 *       "title": "new post",
 *       "translationId": ""
 *     },
 *     { 
 *       "_id": "ccbb6257-ed0e-4521-97df-8b5b207adb00",  
 *       "categoryIds": [
 *         "1ea22fce-bc3c-4b78-9422-f0f367f8628e"  
 *       ],  
 *       "commentingEnabled": true,  
 *       "excerpt": "Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading....",  
 *       "featured": true, 
 *       "firstPublishedDate": "2020-08-05T21:00:00.000Z", 
 *       "hashtags": [ 
 *         "sea",  
 *         "sun" 
 *       ],  
 *       "heroImage": ""
 *       "language": "en", 
 *       "lastPublishedDate": "2020-08-05T21:00:00.000Z",  
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea", 
 *       "minutesToRead": 1, 
 *       "moderationDetails": {},
 *       "pinned": false,  
 *       "pricingPlanIds": [ 
 *         "b6e94a0c-4d0f-435e-9602-0dd61d2aca37"  
 *       ],  
 *       "relatedPostIds": [ 
 *         "425a5dca-c32d-40e6-b2d7-a8ffa3addded"  
 *       ],  
 *       "slug": "my-vacation",  
 *       "tagIds": [ 
 *         "b698f939-cab5-419b-9966-ba0fa3316de9"  
 *       ],  
 *       "title": "My vacation", 
 *       "translationId": "3cd710b7-c28d-4547-9b8a-3c1ec776064b"
 *     } 
 *   ],
 *   "metaData": {
 *     "count": 2,
 *     "offset": 0,
 *     "total": 2
 *   }
 * }
*/
```

## List posts from a blog (export from backend code)

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { posts } from 'wix-blog-backend';

export const listPostsFunction = webMethod(Permissions.Anyone, async () => {
  try {
    const result = await posts.listPosts();
    const firstPostTitle = result.posts[0].title;
    const firstPostExcerpt = result.posts[0].excerpt;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to:
 * {
 *   "posts": [
 *     {
 *       "_id": "0a265609-e16e-4c96-b71a-2a62b513e6c8",
 *       "categoryIds": [],
 *       "commentingEnabled": true,
 *       "excerpt": "some text",
 *       "featured": false,
 *       "firstPublishedDate": "2022-05-25T13:56:19.023Z",
 *       "hashtags": [],
 *       "heroImage": ""
 *       "language": "en",
 *       "lastPublishedDate": "2022-05-25T13:56:19.023Z",
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea",
 *       "minutesToRead": 1,
 *       "pinned": false,
 *       "preview": false,
 *       "pricingPlanIds": [],
 *       "relatedPostIds": [],
 *       "slug": "_new-post",
 *       "tagIds": [],
 *       "title": "new post",
 *       "translationId": ""
 *     },
 *     { 
 *       "_id": "ccbb6257-ed0e-4521-97df-8b5b207adb00",  
 *       "categoryIds": [
 *         "1ea22fce-bc3c-4b78-9422-f0f367f8628e"  
 *       ],  
 *       "commentingEnabled": true,  
 *       "excerpt": "Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading....",  
 *       "featured": true, 
 *       "firstPublishedDate": "2020-08-05T21:00:00.000Z", 
 *       "hashtags": [ 
 *         "sea",  
 *         "sun" 
 *       ],  
 *       "heroImage": ""
 *       "language": "en", 
 *       "lastPublishedDate": "2020-08-05T21:00:00.000Z",  
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea", 
 *       "minutesToRead": 1, 
 *       "moderationDetails": {},
 *       "pinned": false,  
 *       "pricingPlanIds": [ 
 *         "b6e94a0c-4d0f-435e-9602-0dd61d2aca37"  
 *       ],  
 *       "relatedPostIds": [ 
 *         "425a5dca-c32d-40e6-b2d7-a8ffa3addded"  
 *       ],  
 *       "slug": "my-vacation",  
 *       "tagIds": [ 
 *         "b698f939-cab5-419b-9966-ba0fa3316de9"  
 *       ],  
 *       "title": "My vacation", 
 *       "translationId": "3cd710b7-c28d-4547-9b8a-3c1ec776064b"
 *     } 
 *   ],
 *   "metaData": {
 *     "count": 2,
 *     "offset": 0,
 *     "total": 2
 *   }
 * }
*/

```

## List posts from a blog with filter, sorting and paging options 

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { posts } from 'wix-blog-backend';

/* Sample options values:
 * {
 *   featured: false,
 *   categoryIds: [
 *     '6270ef2f8586e65a5e1047bc'
 *   ],
 *   sort: 'PUBLISHED_DATE_ASC',
 *   paging: {
 *     limit: 2
 *   }
 * }  
 */

export const listPostsFunction = webMethod(Permissions.Anyone, async (options) => {
  try {
    const result = await posts.listPosts(options);
    const firstPostTitle = result.posts[0].title;
    const firstPostMemberId = result.posts[0].memberId;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
});

/*
 * {
 *   "posts": [
 *     {
 *       "_id": "ccbb6257-ed0e-4521-97df-8b5b207adb00",  
 *       "categoryIds": [  
 *         "1ea22fce-bc3c-4b78-9422-f0f367f8628e"  
 *       ],  
 *       "commentingEnabled": true,  
 *       "excerpt": "Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading....",  
 *       "featured": true, 
 *       "firstPublishedDate": "2020-08-05T21:00:00.000Z", 
 *       "hashtags": [ 
 *         "sea",  
 *         "sun" 
 *       ],  
 *       "heroImage": ""
 *       "language": "en", 
 *       "lastPublishedDate": "2020-08-05T21:00:00.000Z",  
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea", 
 *       "minutesToRead": 1, 
 *       "moderationDetails": {},
 *       "pinned": false,
 *       "preview": false,
 *       "pricingPlanIds": [ 
 *         "b6e94a0c-4d0f-435e-9602-0dd61d2aca37"  
 *       ],  
 *       "relatedPostIds": [ 
 *         "425a5dca-c32d-40e6-b2d7-a8ffa3addded"  
 *       ],  
 *       "slug": "my-vacation",  
 *       "tagIds": [ 
 *         "b698f939-cab5-419b-9966-ba0fa3316de9"  
 *       ],  
 *       "title": "My vacation", 
 *       "translationId": "3cd710b7-c28d-4547-9b8a-3c1ec776064b",  
 *       "contentId": "62a9b7a4f276b0918225d8ef",
 *       "internalCategoryIds": [],
 *       "internalRelatedPostIds": [],
 *       "mostRecentContributorId": "33d02592-dd28-4eff-9b8e-4c3bb9c737dd"
 *     },
 *     {
 *       "_id": "78e6908f-87c6-4ddc-bc7f-c3150034d80d",
 *       "categoryIds": [
 *         "1ea22fce-bc3c-4b78-9422-f0f367f8628e"
 *       ],
 *       "commentingEnabled": true,
 *       "excerpt": "Let's talk about choosing best peppers for amazing peppercorn sauce",
 *       "featured": false,
 *       "firstPublishedDate": "2021-03-18T11:43:39.408Z",
 *       "hashtags": [],
 *       "heroImage": "",
 *       "language": "en",
 *       "lastPublishedDate": "2021-03-18T11:43:39.408Z",
 *       "media": {
 *         "wixMedia": {
 *           "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
 *         },
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "memberId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea",
 *       "minutesToRead": 1,
 *       "moderationDetails": {},
 *       "pinned": false,
 *       "pricingPlanIds": [],
 *       "relatedPostIds": [],
 *       "slug": "best-peppers-for-peppercorn-sauce",
 *       "tagIds": [
 *         "b698f939-cab5-419b-9966-ba0fa3316de9"
 *       ],
 *       "title": "Best peppers for peppercorn sauce",
 *       "translationId": "",
 *       "coverMedia": {
 *         "enabled": true,
 *         "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773",
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "contentId": "6271a1618586e65a5e1064db",
 *       "coverMedia": {
 *         "enabled": true,
 *         "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773",
 *         "displayed": true,
 *         "custom": false
 *       },
 *       "internalCategoryIds": [],
 *       "internalRelatedPostIds": [],
 *       "mostRecentContributorId": "4b9f4b64-0792-481e-9289-b2550c1bb7ea"
 *     }
 *   ],
 *   "metaData": {
 *     "count": 2,
 *     "offset": 0,
 *     "total": 4
 *   }
 * }
 */

```

---