> 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`). > - 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: getCategory(categoryId: string, options: GetCategoryOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> categories --> getCategory # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/categories/get-category.md # Method Description: Gets a category with the specified ID. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get a category by ID ```javascript import { categories } from 'wix-blog-backend'; /* Sample categoryId value: * 'f489bf39-3297-4854-8429-e19dbefdca0e' */ export async function getCategoryFunction(categoryId) { try { const result = await categories.getCategory(categoryId); const label = result.category.label; const slug = result.category.slug; 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 ID (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { categories } from 'wix-blog-backend'; /* Sample categoryId value: * 'f489bf39-3297-4854-8429-e19dbefdca0e' */ export const getCategoryFunction = webMethod(Permissions.Anyone, async (categoryId) => { try { const result = await categories.getCategory(categoryId); const label = result.category.label; const slug = result.category.slug; 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 ID with additional fields ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { categories } from 'wix-blog-backend'; /* Sample categoryId value: * 'f489bf39-3297-4854-8429-e19dbefdca0e' * * Sample options value: * { * fieldsets: [ * 'URL', * 'SEO' * ] * } */ export const getCategoryFunction = webMethod(Permissions.Anyone, async (categoryId, options) => { try { const result = await categories.getCategory(categoryId, options); const label = result.category.label; const url = 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 Category", * "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e", * "url" : "http://https://tadasz7.wixsite.com/blog-velo-events/my-blog/categories/my-category" * } * } */ ``` ---