Includes front-page, strain archive/single templates, header/footer, functions.php with custom post types, and base styles.
144 lines
6.7 KiB
PHP
144 lines
6.7 KiB
PHP
<?php
|
|
/**
|
|
* Weedops — Main Template File
|
|
*
|
|
* Fallback template used when no more specific template matches.
|
|
* Also serves as the blog/post archive.
|
|
*
|
|
* @package Weedops
|
|
*/
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<?php if ( is_home() && ! is_front_page() ) : ?>
|
|
<header class="wo-page-header wo-mb-3">
|
|
<h1 class="wo-page-title"><?php esc_html_e( 'Latest Posts', 'weedops' ); ?></h1>
|
|
</header>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( have_posts() ) : ?>
|
|
|
|
<div class="wo-grid wo-grid--3">
|
|
<?php while ( have_posts() ) : the_post(); ?>
|
|
|
|
<article id="post-<?php the_ID(); ?>" <?php post_class( 'wo-card' ); ?>>
|
|
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
|
<a href="<?php the_permalink(); ?>" class="wo-card__thumb" aria-hidden="true" tabindex="-1">
|
|
<?php
|
|
the_post_thumbnail( 'medium', [
|
|
'class' => 'wo-card__img',
|
|
'loading' => 'lazy',
|
|
'style' => 'width:100%;height:180px;object-fit:cover;border-radius:8px 8px 0 0;margin:-1.5rem -1.5rem 1rem;width:calc(100% + 3rem);',
|
|
] );
|
|
?>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php // Post type / taxonomy badges ?>
|
|
<div class="wo-card__meta" style="margin-bottom:0.6rem;">
|
|
<?php
|
|
$post_type = get_post_type();
|
|
if ( 'wo_strain' === $post_type ) {
|
|
$types = get_the_terms( get_the_ID(), 'wo_strain_type' );
|
|
if ( $types && ! is_wp_error( $types ) ) {
|
|
foreach ( $types as $t ) {
|
|
weedops_strain_badge( $t->slug );
|
|
}
|
|
}
|
|
} elseif ( 'wo_product' === $post_type ) {
|
|
$cats = get_the_terms( get_the_ID(), 'wo_product_cat' );
|
|
if ( $cats && ! is_wp_error( $cats ) ) {
|
|
echo '<span class="wo-badge" style="background:#1a2e3d;color:#b3d9ff;">';
|
|
echo esc_html( $cats[0]->name );
|
|
echo '</span>';
|
|
}
|
|
} else {
|
|
echo '<span class="wo-text-muted" style="font-size:0.78rem;">';
|
|
echo esc_html( get_the_category_list( ', ' ) );
|
|
echo '</span>';
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
<h2 class="wo-card__title" style="font-size:1.1rem;margin-bottom:0.5rem;">
|
|
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
|
</h2>
|
|
|
|
<?php // Cannabinoid info for strains/products ?>
|
|
<?php if ( in_array( $post_type, [ 'wo_strain', 'wo_product' ], true ) ) : ?>
|
|
<?php $canna_str = weedops_get_cannabinoid_str( get_the_ID() ); ?>
|
|
<?php if ( $canna_str ) : ?>
|
|
<p style="font-size:0.82rem;font-weight:600;color:var(--wo-green-mid);margin-bottom:0.5rem;">
|
|
<?php echo esc_html( $canna_str ); ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<div class="wo-card__excerpt" style="font-size:0.875rem;color:var(--wo-text-muted);margin-bottom:1rem;">
|
|
<?php the_excerpt(); ?>
|
|
</div>
|
|
|
|
<div class="wo-card__footer" style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:0.5rem;">
|
|
<a href="<?php the_permalink(); ?>" class="wo-btn wo-btn--outline" style="font-size:0.8rem;padding:0.4rem 0.8rem;">
|
|
<?php esc_html_e( 'View Details', 'weedops' ); ?>
|
|
</a>
|
|
|
|
<?php // COA badge for lab-tested products ?>
|
|
<?php if ( 'wo_product' === $post_type && weedops_has_valid_coa( get_the_ID() ) ) : ?>
|
|
<span class="wo-compliance-tag wo-compliance-tag--ok">
|
|
✓ <?php esc_html_e( 'Lab Tested', 'weedops' ); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
|
|
<?php // Date for blog posts ?>
|
|
<?php if ( 'post' === $post_type ) : ?>
|
|
<time datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>" style="font-size:0.78rem;color:var(--wo-text-muted);">
|
|
<?php echo esc_html( get_the_date() ); ?>
|
|
</time>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
</article>
|
|
|
|
<?php endwhile; ?>
|
|
</div><!-- .wo-grid -->
|
|
|
|
<?php // Pagination ?>
|
|
<nav class="wo-pagination wo-mt-3" role="navigation" aria-label="<?php esc_attr_e( 'Posts pagination', 'weedops' ); ?>">
|
|
<?php
|
|
the_posts_pagination( [
|
|
'mid_size' => 2,
|
|
'prev_text' => '← ' . __( 'Previous', 'weedops' ),
|
|
'next_text' => __( 'Next', 'weedops' ) . ' →',
|
|
'before_page_number' => '<span class="wo-sr-only">' . __( 'Page', 'weedops' ) . ' </span>',
|
|
] );
|
|
?>
|
|
</nav>
|
|
|
|
<?php else : ?>
|
|
|
|
<?php // No posts found ?>
|
|
<section class="wo-card wo-text-center" style="max-width:560px;margin:4rem auto;">
|
|
<svg width="56" height="56" viewBox="0 0 28 28" fill="none" aria-hidden="true" style="margin:0 auto 1rem;display:block;opacity:0.25;">
|
|
<path d="M14 2C8.5 2 4 6.5 4 12c0 3.5 2 6.5 5 8.5L14 26l5-5.5c3-2 5-5 5-8.5C24 6.5 19.5 2 14 2z" fill="#1a3d2b"/>
|
|
</svg>
|
|
<h2 style="font-size:1.3rem;"><?php esc_html_e( 'Nothing found', 'weedops' ); ?></h2>
|
|
<p class="wo-text-muted wo-mt-1">
|
|
<?php esc_html_e( 'No content matches your query. Try searching or browse our strain database.', 'weedops' ); ?>
|
|
</p>
|
|
<div class="wo-mt-2">
|
|
<?php get_search_form(); ?>
|
|
</div>
|
|
<div class="wo-mt-2">
|
|
<a href="<?php echo esc_url( home_url( '/strains' ) ); ?>" class="wo-btn wo-btn--primary">
|
|
<?php esc_html_e( 'Browse Strains', 'weedops' ); ?>
|
|
</a>
|
|
</div>
|
|
</section>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
get_footer();
|