> 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: getCategoryBySlug(slug: string, options: GetCategoryBySlugOptions)

# Method package: wixBlogBackend

# Method menu location: wixBlogBackend --> categories --> getCategoryBySlug

# Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/categories/get-category-by-slug.md

# Method Description:

Gets a category with the specified slug.

The slug is at the end of the URL of a specific category.
For example, if a category's URL is `https://example.com/blog/categories/famous-cats`, the slug is `famous-cats`.
The slug is a case-sensitive string that is derived from the category's label, unless specified otherwise.



# Method Code Examples:

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

## Get a category by its slug

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

/* Sample slug value:
 * 'my-category'
 */

export async function getCategoryBySlugFunction(slug) {
  try {
    const result = await categories.getCategoryBySlug(slug);
    const label = result.category.label;
    const slugId = result.category._id;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "category": {
 *     "_id": "f489bf39-3297-4854-8429-e19dbefdca0e",
 *     "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245",
 *     "description": "my category description",
 *     "displayPosition": 0,
 *     "label": "My Category",
 *     "language": "en",
 *     "postCount": 1,
 *     "slug": "my-category",
 *     "title": "My Category",
 *     "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e"
 *   }
 * }
 */

```

## Get a category by its slug (export from backend code)

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

/* Sample slug value:
 * 'my-category'
 */

export const getCategoryBySlugFunction = webMethod(Permissions.Anyone, async (slug) => {
  try {
    const result = await categories.getCategoryBySlug(slug);
    const label = result.category.label;
    const slugId = result.category._id;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to:
 * {
 *   "category": {
 *     "_id": "f489bf39-3297-4854-8429-e19dbefdca0e",
 *     "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245",
 *     "description": "my category description",
 *     "displayPosition": 0,
 *     "label": "My Category",
 *     "language": "en",
 *     "postCount": 1,
 *     "slug": "my-category",
 *     "title": "My Category",
 *     "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e"
 *   }
 * }
 */
```

## Get a category by slug with additional fields 

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

/* Sample slug value:
 * 'my-category'
 * Sample options value:
 * {
 *   fieldsets: [
 *     'URL',
 *     'SEO'
 *   ]
 * }
 */

export const getCategoryBySlugFunction = webMethod(Permissions.Anyone, async (slug, options) => {
  try {
    const result = await categories.getCategoryBySlug(slug, options);
    const label = result.category.label;
    const slugId = result.category._id;
    const slugUrl = result.category.url;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to:
 * {
 *   "category": {
 *     "_id": "f489bf39-3297-4854-8429-e19dbefdca0e",
 *     "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245",
 *     "description": "my category description",
 *     "displayPosition": 0,
 *     "label": "My Category",
 *     "language": "en",
 *     "postCount": 1,
 *     "seoData": {
 *       "tags": [
 *         {
 *           "type": "meta",
 *           "props": {
 *             "name": "description",
 *             "content": "this is a category description"
 *           },
 *           "children": "",
 *           "custom": false,
 *           "disabled": false
 *         }
 *       ]
 *     },
 *     "slug": "my-category",
 *     "title": "My Title",
 *     "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e",
 *     "url" : "http://https://tadasz7.wixsite.com/blog-velo-events/my-blog/categories/my-category"
 *   }
 * }
 */
```

---