📄 One Page, Different Layout
Default page template is boring. Custom page templates create unique layouts. Landing pages, full-width, sidebar left/right.
📝 Creating Page Template
// page-templates/landing.php
<?php
/*
Template Name: Landing Page
Description: Full-width landing page template
*/
get_header(); ?>
<main id="main" class="site-main landing-page">
<?php
while (have_posts()) :
the_post();
the_content();
endwhile;
?>
</main>
<?php get_footer(); ?>
// Add full-width CSS
.landing-page {
max-width: 100%;
padding: 0;
}
.landing-page .entry-content {
max-width: 100%;
}
🎯 Using Page Templates
1. Create new page or edit existing 2. Page Attributes → Template 3. Select your custom template 4. Publish Template examples: - Full-width page (no sidebar) - Landing page (no header/footer) - Sidebar left - Sidebar right - Custom portfolio layout - Contact page with map Multiple templates: // page-templates/sidebar-left.php // page-templates/sidebar-right.php // page-templates/full-width.php
💡 Pro Tips
- Use naming convention: page-templates/template-name.php
- Template comments: /* Template Name: Landing Page */
- Use conditional logic inside templates
- Create custom fields for template-specific data
“Custom page templates gave clients unique landing pages. No more cookie-cutter pages. Essential for WordPress development.”
