WordPress Integration
Deep dive into how TheDock integrates with WordPress.
Overview
TheDock is built for WordPress from the ground up. It respects WordPress conventions while providing a modern visual building experience.
Posts and Pages
Dynamic Content
TheDock templates can display WordPress content dynamically:
- Post Loops - Display lists of posts
- Single Post Content - Show individual post/page content
- Featured Images - Display post thumbnails
- Post Meta - Show dates, authors, categories
Post Loop Block
The Post Loop block displays multiple posts:
| Setting | Description |
|---|---|
| Post Type | Posts, pages, custom types |
| Posts Per Page | Number to display |
| Order By | Date, title, menu order, random |
| Categories/Tags | Filter by taxonomy |
| Layout | Grid, list, masonry |
Page Content Block
Displays the main content of a page/post:
- Renders WordPress editor content
- Respects formatting and embeds
- Includes Gutenberg blocks
Menus
WordPress Menu System
TheDock uses native WordPress menus:
- Create menus in Appearance > Menus
- Assign locations in TheDock
Menu Locations
Configure in C. Build > Menu Locations:
| Location | Typical Use |
|---|---|
| Primary | Main navigation |
| Secondary | Top bar links |
| Footer | Footer navigation |
| Mobile | Mobile-specific menu |
Using Menus in Templates
Navigation blocks reference menu locations:
- Add a Navigation block
- Select the menu location
- Style the navigation
Menu Features
TheDock supports:
- Multi-level menus (dropdowns)
- Custom link classes
- Menu icons
- Mega menus (with configuration)
Featured Images
Post Thumbnails
TheDock fully supports WordPress featured images:
- In loops - Thumbnails for post listings
- In singles - Hero images for individual posts
- In headers - Dynamic background images
Image Sizes
WordPress generates multiple image sizes. TheDock uses:
| Size | Typical Use |
|---|---|
| Thumbnail | Small previews |
| Medium | Inline images |
| Large | Full-width images |
| Full | Original size |
| Custom | TheDock-specific sizes |
Responsive Images
TheDock outputs responsive srcset attributes for optimal loading.
Widgets (Legacy)
While TheDock provides better alternatives, WordPress widgets are supported:
Widget Areas
Define widget areas in Theme Functions:
<?php
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'sidebar-1',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
));
Using Widgets
Add a Widget Area block in your template to display widgets.
WordPress Settings
Reading Settings
TheDock respects WordPress Reading settings:
- Homepage displays - Static page vs latest posts
- Posts per page - Default post count
Permalinks
TheDock templates work with any permalink structure.
Discussion Settings
Comment templates integrate with WordPress discussion settings.
WordPress Hooks
TheDock fires WordPress hooks appropriately:
Template Hooks
<?php
// Header
wp_head()
wp_body_open()
// Footer
wp_footer()
Content Hooks
<?php
// Before/after content
the_content()
Custom Hooks
Add your own via Theme Functions:
<?php
do_action('my_custom_hook');
WordPress Conditionals
TheDock templates can use WordPress conditionals:
Common Conditionals
| Conditional | True When |
|---|---|
is_front_page() | Viewing homepage |
is_home() | Viewing blog page |
is_single() | Viewing single post |
is_page() | Viewing a page |
is_archive() | Viewing archive |
is_search() | Viewing search results |
is_404() | Viewing 404 page |
is_user_logged_in() | User is logged in |
Using in Templates
TheDock allows conditional visibility:
- Show/hide sections based on conditions
- Different content for logged-in users
- Device-specific display
Multisite Support
TheDock works with WordPress Multisite:
Considerations
- Each site has its own TheDock configuration
- Theme can be network-activated
- Configurations are site-specific
Network Setup
- Network-activate TheDock plugin
- Configure each site individually
- Or set up a "base" site and clone
WordPress REST API
TheDock can integrate with the REST API:
Using API Data
Custom blocks can fetch API data:
fetch('/wp-json/wp/v2/posts')
.then(response => response.json())
.then(posts => {
// Render posts
});
Custom Endpoints
Register custom endpoints in Theme Functions:
<?php
add_action('rest_api_init', function() {
register_rest_route('mytheme/v1', '/featured', array(
'methods' => 'GET',
'callback' => 'get_featured_content'
));
});
Gutenberg Compatibility
Block Editor Content
TheDock renders Gutenberg blocks correctly:
- Block content displays in templates
- Block styling is respected
- Custom blocks work
TheDock vs Gutenberg
| TheDock | Gutenberg |
|---|---|
| Theme-level design | Content-level editing |
| Page templates | Page/post content |
| Design system | Individual blocks |
They complement each other:
- Use TheDock for templates and design
- Use Gutenberg for content editing
Performance
Optimization Features
TheDock includes:
- Minified CSS output
- Optimized asset loading
- Responsive image handling
- Clean HTML structure
Recommended Plugins
Pair TheDock with:
- Caching plugins (WP Super Cache, W3TC)
- Image optimization (ShortPixel, Imagify)
- CDN integration (Cloudflare)
Troubleshooting
Menu not showing
- Verify menu is created in WordPress
- Check menu location assignment
- Ensure template has navigation block
Featured images missing
- Verify images are set in WordPress
- Check image size settings
- Verify template uses featured image block
Content not displaying
- Check Post Content block is in template
- Verify correct template is assigned
- Review WordPress editor content
Hooks not firing
- Ensure export is complete
- Check template structure
- Verify functions.php isn't overriding
Related Topics
- Theme Structure - Template assignment
- Custom Fields - ACF integration
- Custom Code - PHP functions