Overview
The VENCOL Front Template integrates with WordPress as a headless CMS, fetching content via the WordPress REST API. This approach combines the power of WordPress content management with the performance of a React frontend.WordPress API Configuration
API Endpoint
The WordPress REST API is configured inlib/wordpress.ts:
wordpress.ts
Data Types
WordPress Post Interface
Internal interface for raw WordPress API responses:wordpress.ts
Application Types
Application-friendly interfaces defined intypes.ts:
types.ts
Utility Functions
HTML Stripping
WordPress returns titles and excerpts with HTML tags. This function cleans them:wordpress.ts
Date Formatting
Converts WordPress date format to localized Spanish format:wordpress.ts
"3 mar 2026"
Data Mapping
Blog Post Mapping
Transforms WordPress post format to application format:wordpress.ts
Featured images and categories are extracted from the
_embedded object when using the _embed query parameter.Page Mapping
Transforms WordPress page format:wordpress.ts
API Functions
Fetching Blog Posts
Retrieves multiple blog posts:wordpress.ts
Home.tsx
Fetching Pages by Slug
Retrieves a single page by its slug:wordpress.ts
PageDetail.tsx
WordPress REST API Parameters
Embedding Related Data
The_embed parameter includes related data in the response:
- Featured images (
wp:featuredmedia) - Author information (
author) - Categories and tags (
wp:term)
Common Query Parameters
Example:
Error Handling
Graceful Degradation
The application uses fallback data when WordPress is unavailable:Home.tsx
404 Handling
When a page is not found:PageDetail.tsx
Loading States
Display loading skeleton while fetching:PageDetail.tsx
Rendering WordPress Content
Dangerously Set HTML
WordPress content includes HTML that needs to be rendered:PageDetail.tsx
Prose Styling
Tailwind Typography plugin provides prose classes for rich content:WordPress Image Handling
Featured Images
Featured images are extracted from embedded data:Image Alignment Classes
Custom CSS supports WordPress image alignment:index.html
SEO Integration
WordPress content is used for SEO metadata:PageDetail.tsx
Best Practices
Always Use _embed Parameter
Always Use _embed Parameter
Include
_embed in API requests to get featured images and categories in a single request:Implement Fallback Data
Implement Fallback Data
Always provide fallback data for when WordPress is unavailable:
Handle Loading States
Handle Loading States
Implement proper loading UI to improve perceived performance:
Sanitize Content
Sanitize Content
WordPress content is trusted in this application, but if you allow user-generated content, implement proper sanitization before rendering HTML.
Use TypeScript Types
Use TypeScript Types
Define proper TypeScript interfaces for all WordPress data:
Extending the Integration
Adding Custom Post Types
To fetch custom post types:Adding Custom Fields
If using ACF or custom fields:Pagination Support
Implement pagination for blog listing:Related Topics
Architecture
Understand the overall application structure
Routing
Learn about dynamic page routing
Styling
Explore WordPress content styling