<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Dolfansnyc
*/
get_header();
?>
<div class="container">
<div class="row">
<main class="col-lg-8 main-content">
<?php
if ( have_posts() ) :
$post_count = 0;
$is_mobile = isset($_GET['mobile']) && $_GET['mobile'] === '1';
while ( have_posts() ) : the_post();
$post_count++;
if ( $post_count === 1 && is_home() && ! is_paged() ) : ?>
<!-- Featured Post (only on first page, both mobile and desktop) -->
<article class="dolfans-featured-post">
<div class="featured-post-content">
<h2 class="post-title featured-post-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<span class="featured-post-date"><?php echo get_the_date('F j, Y'); ?></span>
<div class="featured-post-excerpt entry-content">
<?php
if ( $is_mobile ) {
// On mobile, show only first 500 characters
$content = get_the_content();
$excerpt = wp_strip_all_tags($content);
$excerpt = substr($excerpt, 0, 500);
// Add ellipsis if content was truncated
if (strlen(wp_strip_all_tags($content)) > 500) {
$excerpt .= '...';
}
echo '<p>' . esc_html($excerpt) . '</p>';
echo '<a href="' . get_permalink() . '" class="featured-read-more">Read More →</a>';
} else {
// On desktop, show full content
the_content();
}
?>
</div>
</div>
</article>
<!-- Remaining Posts -->
<div class="remaining-posts-section">
<div class="posts-grid">
<?php else : ?>
<!-- Regular Post in Grid -->
<article class="dolfans-post">
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php echo dolfansnyc_get_post_image('large'); ?>
</a>
</div>
<div class="post-content">
<h2 class="post-title post-title-condensed">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<div class="post-meta">
<span class="post-date"><?php echo get_the_date('F j, Y'); ?></span>
</div>
<div class="post-excerpt">
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="featured-read-more">
Read More →
</a>
</div>
</div>
</article>
<?php endif;
endwhile;
// Close the remaining posts section if we had more than 1 post on first page
if ( $post_count > 1 && is_home() && ! is_paged() ) : ?>
</div>
</div>
<?php endif;
// Display pagination
dolfansnyc_pagination();
else :
// No posts found
get_template_part( 'template-parts/content', 'none' );
endif; ?>
</main>
<?php
get_sidebar();
?>
</div>
</div>
<?php
get_footer();