Files
homeproz/wp-content/themes/homeproz/single-property.php
T
Hanson.xyz Dev ef12be70ca Add Agent CPT with single-agent profile template
- Created Agent custom post type with ACF fields (phone, email, website, title, license, bio, gallery, social links repeater)
- Added single-agent.php template with modern profile layout: header with photo/contact buttons/social links, biography section, photo gallery, current listings, sidebar contact card
- Created single-agent.scss with responsive styling matching HomeProz dark theme
- Updated single-property.php sidebar: moved property header widget, added document downloads with primary button styling
- Imported 4 agents from homeprozrealestate.com with profile images
- Added agent scrape scripts for reference

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 18:38:49 -06:00

279 lines
14 KiB
PHP
Executable File

<?php
/**
* Single Property Template
*
* @package HomeProz
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
get_header();
while (have_posts()) :
the_post();
$property_id = get_the_ID();
// Get property data
$price = get_field('property_price', $property_id);
$street_address = get_field('street_address', $property_id);
$city = get_field('city', $property_id);
$state = get_field('state', $property_id);
$zip_code = get_field('zip_code', $property_id);
$mls_number = get_field('mls_number', $property_id);
$bedrooms = get_field('bedrooms', $property_id);
$bathrooms = get_field('bathrooms', $property_id);
$square_feet = get_field('square_feet', $property_id);
$lot_size = get_field('lot_size', $property_id);
$year_built = get_field('year_built', $property_id);
$garage = get_field('garage', $property_id);
$short_description = get_field('short_description', $property_id);
$property_features = get_field('property_features', $property_id);
$gallery = get_field('property_gallery', $property_id);
$listing_agent = get_field('listing_agent', $property_id);
$property_documents = get_field('property_documents', $property_id);
// Get status from taxonomy
$status_terms = get_the_terms($property_id, 'property_status');
$status = $status_terms && !is_wp_error($status_terms) ? $status_terms[0]->name : '';
$status_class = homeproz_get_status_class($status);
// Get type from taxonomy
$type_terms = get_the_terms($property_id, 'property_type');
$type = $type_terms && !is_wp_error($type_terms) ? $type_terms[0]->name : '';
// Format full address
$full_address = $street_address;
if ($city) $full_address .= ', ' . $city;
if ($state) $full_address .= ', ' . $state;
if ($zip_code) $full_address .= ' ' . $zip_code;
?>
<main id="primary" class="site-main single-property-main">
<!-- Breadcrumbs -->
<nav class="breadcrumbs" aria-label="Breadcrumb">
<div class="container">
<ol class="breadcrumb-list">
<li><a href="<?php echo esc_url(home_url('/')); ?>">Home</a></li>
<li><a href="<?php echo esc_url(get_post_type_archive_link('property')); ?>">Properties</a></li>
<li aria-current="page"><?php echo esc_html($street_address ?: get_the_title()); ?></li>
</ol>
</div>
</nav>
<div class="container">
<div class="single-property-layout">
<!-- Main Content -->
<div class="single-property-content">
<!-- Gallery -->
<?php get_template_part('template-parts/property/property-gallery', null, array('gallery' => $gallery, 'property_id' => $property_id)); ?>
<!-- Property Specs -->
<?php if ($bedrooms || $bathrooms || $square_feet || $lot_size || $year_built || $garage) : ?>
<section class="property-specs-section">
<h2 class="section-title">Property Details</h2>
<ul class="property-specs-grid">
<?php if ($bedrooms) : ?>
<li class="spec-item">
<span class="spec-label">Bedrooms</span>
<span class="spec-value"><?php echo esc_html($bedrooms); ?></span>
</li>
<?php endif; ?>
<?php if ($bathrooms) : ?>
<li class="spec-item">
<span class="spec-label">Bathrooms</span>
<span class="spec-value"><?php echo esc_html($bathrooms); ?></span>
</li>
<?php endif; ?>
<?php if ($square_feet) : ?>
<li class="spec-item">
<span class="spec-label">Square Feet</span>
<span class="spec-value"><?php echo esc_html(number_format($square_feet)); ?></span>
</li>
<?php endif; ?>
<?php if ($lot_size) : ?>
<li class="spec-item">
<span class="spec-label">Lot Size</span>
<span class="spec-value"><?php echo esc_html($lot_size); ?></span>
</li>
<?php endif; ?>
<?php if ($year_built) : ?>
<li class="spec-item">
<span class="spec-label">Year Built</span>
<span class="spec-value"><?php echo esc_html($year_built); ?></span>
</li>
<?php endif; ?>
<?php if ($garage) : ?>
<li class="spec-item">
<span class="spec-label">Garage</span>
<span class="spec-value"><?php echo esc_html($garage); ?> Car</span>
</li>
<?php endif; ?>
</ul>
</section>
<?php endif; ?>
<!-- Documents -->
<?php if ($property_documents && is_array($property_documents)) : ?>
<section class="property-documents">
<ul class="documents-list">
<?php foreach ($property_documents as $doc) :
if (!$doc['file']) continue;
$file = $doc['file'];
$label = $doc['label'] ?: $file['filename'];
$ext = pathinfo($file['filename'], PATHINFO_EXTENSION);
?>
<li class="document-item">
<a href="<?php echo esc_url($file['url']); ?>" class="document-link btn btn-secondary" target="_blank" download>
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="12" y1="18" x2="12" y2="12"/>
<polyline points="9 15 12 18 15 15"/>
</svg>
<?php echo esc_html($label); ?>
<span class="document-ext">(<?php echo esc_html(strtoupper($ext)); ?>)</span>
</a>
</li>
<?php endforeach; ?>
</ul>
</section>
<?php endif; ?>
<!-- Description -->
<section class="property-description">
<h2 class="section-title">Description</h2>
<?php if ($short_description) : ?>
<p class="property-short-desc"><?php echo esc_html($short_description); ?></p>
<?php endif; ?>
<div class="property-full-desc">
<?php the_content(); ?>
</div>
</section>
<!-- Features -->
<?php if ($property_features && is_array($property_features)) : ?>
<section class="property-features">
<h2 class="section-title">Features & Amenities</h2>
<ul class="features-list">
<?php
$feature_labels = array(
'central_air' => 'Central Air',
'central_heat' => 'Central Heat',
'fireplace' => 'Fireplace',
'hardwood_floors' => 'Hardwood Floors',
'updated_kitchen' => 'Updated Kitchen',
'updated_bathrooms' => 'Updated Bathrooms',
'basement' => 'Basement',
'finished_basement' => 'Finished Basement',
'deck_patio' => 'Deck/Patio',
'pool' => 'Pool',
'fenced_yard' => 'Fenced Yard',
'sprinkler_system' => 'Sprinkler System',
'smart_home' => 'Smart Home Features',
'solar_panels' => 'Solar Panels',
'new_roof' => 'New Roof',
'new_windows' => 'New Windows',
'waterfront' => 'Waterfront',
'lake_access' => 'Lake Access',
);
foreach ($property_features as $feature) :
$label = isset($feature_labels[$feature]) ? $feature_labels[$feature] : ucwords(str_replace('_', ' ', $feature));
?>
<li class="feature-item">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" aria-hidden="true">
<polyline points="20 6 9 17 4 12"/>
</svg>
<?php echo esc_html($label); ?>
</li>
<?php endforeach; ?>
</ul>
</section>
<?php endif; ?>
</div>
<!-- Sidebar -->
<aside class="single-property-sidebar">
<!-- Property Header -->
<div class="sidebar-widget property-header-widget">
<div class="property-header-top">
<?php if ($status) : ?>
<span class="badge <?php echo esc_attr($status_class); ?>"><?php echo esc_html($status); ?></span>
<?php endif; ?>
<?php if ($type) : ?>
<span class="property-type"><?php echo esc_html($type); ?></span>
<?php endif; ?>
</div>
<h1 class="property-title"><?php echo esc_html(homeproz_format_price($price)); ?></h1>
<p class="property-address">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
<circle cx="12" cy="10" r="3"/>
</svg>
<?php echo esc_html($full_address); ?>
</p>
<?php if ($mls_number) : ?>
<p class="property-mls">MLS# <?php echo esc_html($mls_number); ?></p>
<?php endif; ?>
</div>
<!-- Property Documents -->
<div class="sidebar-widget property-documents-widget">
<h3 class="widget-title">Property Documents</h3>
<?php if ($property_documents && is_array($property_documents) && !empty($property_documents)) : ?>
<div class="sidebar-documents-list">
<?php foreach ($property_documents as $doc) :
if (!$doc['file']) continue;
$file = $doc['file'];
$label = $doc['label'] ?: $file['filename'];
$ext = strtoupper(pathinfo($file['filename'], PATHINFO_EXTENSION));
?>
<a href="<?php echo esc_url($file['url']); ?>" class="document-btn" target="_blank">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
<span class="document-btn-label"><?php echo esc_html($label); ?></span>
<span class="document-btn-ext"><?php echo esc_html($ext); ?></span>
</a>
<?php endforeach; ?>
</div>
<?php else : ?>
<!-- Mock documents for display -->
<div class="sidebar-documents-list">
<a href="#" class="document-btn" onclick="return false;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
<span class="document-btn-label">Property Disclosure</span>
<span class="document-btn-ext">PDF</span>
</a>
<a href="#" class="document-btn" onclick="return false;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
<span class="document-btn-label">Floor Plan</span>
<span class="document-btn-ext">PDF</span>
</a>
</div>
<?php endif; ?>
</div>
<!-- Contact Agent -->
<?php get_template_part('template-parts/property/property-agent', null, array('agent' => $listing_agent, 'property_id' => $property_id)); ?>
</aside>
</div>
</div>
</main>
<?php
endwhile;
get_footer();