feat: add content feed with AJAX filtering and load more on front page

This commit is contained in:
2026-04-03 01:13:09 +05:00
parent 82105c6f09
commit 8f1f001085
7 changed files with 484 additions and 1 deletions
@@ -0,0 +1,78 @@
<?php
/**
* БИТ.WMS Child Theme — templates/content-card.php
*
* Universal content card used in the content feed section and AJAX responses.
* Reads the current post from The Loop (global $post).
*
* @package bitwms-child
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Map post_type to label. For 'post' also check for "news" category.
$type_labels = array(
'case' => __( 'Кейс', 'bitwms-child' ),
'webinar' => __( 'Вебинар', 'bitwms-child' ),
'course' => __( 'Курс', 'bitwms-child' ),
'event' => __( 'Мероприятие', 'bitwms-child' ),
'material' => __( 'Материал', 'bitwms-child' ),
);
$post_type = get_post_type();
$badge_text = '';
if ( 'post' === $post_type ) {
if ( has_category( 'news' ) ) {
$badge_text = __( 'Новость', 'bitwms-child' );
} else {
$badge_text = __( 'Статья', 'bitwms-child' );
}
} elseif ( isset( $type_labels[ $post_type ] ) ) {
$badge_text = $type_labels[ $post_type ];
}
// Trim excerpt to 15 words.
$excerpt = get_the_excerpt();
if ( $excerpt ) {
$words = explode( ' ', $excerpt );
$excerpt = implode( ' ', array_slice( $words, 0, 15 ) );
if ( count( $words ) > 15 ) {
$excerpt .= '…';
}
}
?>
<article class="content-card" data-post-type="<?php echo esc_attr( $post_type ); ?>">
<a href="<?php the_permalink(); ?>" class="content-card__link">
<div class="content-card__image">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'medium_large', array( 'alt' => esc_attr( get_the_title() ) ) ); ?>
<?php else : ?>
<div class="content-card__placeholder" aria-hidden="true"></div>
<?php endif; ?>
</div>
<div class="content-card__body">
<?php if ( $badge_text ) : ?>
<span class="badge"><?php echo esc_html( $badge_text ); ?></span>
<?php endif; ?>
<h3 class="content-card__title"><?php the_title(); ?></h3>
<?php if ( $excerpt ) : ?>
<p class="content-card__excerpt"><?php echo esc_html( $excerpt ); ?></p>
<?php endif; ?>
<div class="content-card__meta">
<time datetime="<?php echo esc_attr( get_the_date( 'Y-m-d' ) ); ?>">
<?php echo esc_html( get_the_date( 'd.m.Y' ) ); ?>
</time>
</div>
</div>
</a>
</article>