Files
homeproz/wp-content/themes/homeproz/template-resource.php
T
Hanson.xyz Dev 837b3219fb Standardize interior page heroes with ACF customization
- Enhance archive-hero to support optional background images
- Add Page Hero ACF fields (title, subtitle, background) for all pages
- Add Properties Page hero settings in Theme Options
- Update all page templates to use consistent archive-hero style
- Resource pages now use archive-hero with featured image fallback

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 22:51:04 -06:00

123 lines
4.9 KiB
PHP

<?php
/**
* Template Name: Resource Page
*
* Template for individual resource/guide pages
*
* @package HomeProz
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
get_header();
?>
<main id="primary" class="site-main resource-page-main">
<?php
// Get hero content from ACF (Page Hero fields) or defaults
$hero_title = get_field('hero_title') ?: get_the_title();
$hero_subtitle = get_field('hero_subtitle') ?: get_the_excerpt() ?: 'A comprehensive guide from HomeProz Real Estate';
$hero_bg = get_field('hero_background');
// Fall back to featured image if no ACF background set
if (!$hero_bg) {
$hero_bg = get_the_post_thumbnail_url(get_the_ID(), 'full');
}
$has_bg_class = $hero_bg ? 'has-background' : '';
$bg_style = $hero_bg ? 'style="background-image: url(' . esc_url($hero_bg) . ');"' : '';
?>
<!-- Archive Hero -->
<section class="archive-hero <?php echo esc_attr($has_bg_class); ?>" <?php echo $bg_style; ?>>
<?php if ($hero_bg) : ?>
<div class="archive-hero-overlay"></div>
<?php endif; ?>
<div class="container">
<h1 class="archive-hero-title"><?php echo esc_html($hero_title); ?></h1>
<?php if ($hero_subtitle) : ?>
<p class="archive-hero-subtitle"><?php echo esc_html($hero_subtitle); ?></p>
<?php endif; ?>
</div>
</section>
<!-- Resource Content Section -->
<section class="resource-content-section">
<div class="container">
<div class="resource-content-layout">
<!-- Main Content -->
<article class="resource-content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</article>
<!-- Sidebar -->
<aside class="resource-sidebar">
<div class="resource-sidebar-sticky">
<!-- Quick Contact -->
<div class="resource-sidebar-card">
<h3>Need Help?</h3>
<p>Our agents are ready to assist you with any questions.</p>
<a href="<?php echo esc_url(home_url('/contact/')); ?>" class="btn btn-primary btn-block">
Contact Us
</a>
<p class="resource-sidebar-phone">
Or call: <a href="tel:<?php echo esc_attr(preg_replace('/[^0-9]/', '', homeproz_get_option('phone'))); ?>"><?php echo esc_html(homeproz_get_option('phone')); ?></a>
</p>
</div>
<!-- Related Resources -->
<div class="resource-sidebar-card">
<h3>Related Resources</h3>
<ul class="resource-sidebar-links">
<?php
// Get sibling pages
$parent_id = wp_get_post_parent_id(get_the_ID());
if ($parent_id) {
$siblings = get_pages(array(
'parent' => $parent_id,
'exclude' => get_the_ID(),
'sort_column' => 'menu_order',
));
foreach ($siblings as $sibling) :
?>
<li>
<a href="<?php echo esc_url(get_permalink($sibling->ID)); ?>">
<?php echo esc_html($sibling->post_title); ?>
</a>
</li>
<?php
endforeach;
}
?>
<li>
<a href="<?php echo esc_url(home_url('/resources/')); ?>">
View All Resources
</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
</div>
</section>
<?php
// Contact CTA Section
get_template_part('template-parts/components/cta-section', null, array(
'title' => 'Ready to Get Started?',
'text' => 'Let our experienced team help you achieve your real estate goals.',
'button_text' => 'Contact an Agent',
'button_url' => home_url('/contact/'),
'style' => 'accent',
));
?>
</main>
<?php
get_footer();