Ansico-CPT/ansico-cpt-and-taxonomies/templates/archive-cpt.php

46 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2026-04-16 18:48:19 +00:00
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
get_header();
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) ) {
$post_type = reset( $post_type );
}
$settings = function_exists( 'ansico_cptax' ) ? ansico_cptax()->get_cpt_template_settings( $post_type ) : array();
$columns = max( 1, min( 4, (int) ( $settings['archive_columns'] ?? 3 ) ) );
$min_card = 100 / $columns;
?>
<main id="primary" class="site-main ansico-cpt-archive" style="max-width:1100px;margin:40px auto;padding:0 20px;">
<header class="page-header" style="margin-bottom:30px;">
<h1 class="page-title"><?php post_type_archive_title(); ?></h1>
<?php the_archive_description( '<div class="archive-description">', '</div>' ); ?>
<?php if ( ! empty( $settings['archive_intro'] ) ) : ?>
<div class="archive-description"><?php echo wp_kses_post( wpautop( $settings['archive_intro'] ) ); ?></div>
<?php endif; ?>
</header>
<?php if ( have_posts() ) : ?>
<div class="ansico-grid" style="display:grid;grid-template-columns:repeat(<?php echo (int) $columns; ?>, minmax(0, 1fr));gap:24px;">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="border:1px solid #ddd;border-radius:8px;padding:20px;">
<?php if ( ! empty( $settings['archive_show_featured'] ) && has_post_thumbnail() ) : ?>
<div style="margin-bottom:12px;"><?php the_post_thumbnail( 'medium' ); ?></div>
<?php endif; ?>
<h2 style="margin-top:0;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php if ( ! empty( $settings['archive_show_meta'] ) ) : ?>
<p style="color:#666;font-size:0.95em;"><?php echo esc_html( get_the_date() ); ?></p>
<?php endif; ?>
<?php if ( ! empty( $settings['archive_show_excerpt'] ) ) : ?>
<div><?php the_excerpt(); ?></div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</div>
<div style="margin-top:24px;"><?php the_posts_pagination(); ?></div>
<?php else : ?>
<p><?php esc_html_e( 'No content found.', 'ansico-cpt-and-taxonomies' ); ?></p>
<?php endif; ?>
</main>
<?php get_footer(); ?>