Files
tylkofotografia/search.php
2026-01-15 12:23:11 +01:00

129 lines
3.2 KiB
PHP

<?php
/**
* Strona wyników wyszukiwania
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
$postcount = 0;
get_header(); ?>
<main>
<?php if ( have_posts() ) {
?>
<div class="content" id="main" style="margin-top: 60px;">
<div class="container">
<div class="row">
<div class="col">
<h2 class="text-center">
<?php
printf(
/* translators: %s: Search term. */
esc_html__( 'Wyniki wyszukiwania dla frazy "%s"', 'twentytwentyone' ),
'<span class="page-description search-term">' . esc_html( get_search_query() ) . '</span>'
);
?>
</h2>
<p class="text-center">
<?php
printf(
esc_html(
/* translators: %d: The number of search results. */
_n(
'Znaleziono %d wynik.',
'Znaleziono %d wyników.',
(int) $wp_query->found_posts,
'twentytwentyone'
)
),
(int) $wp_query->found_posts
);
?>
</p>
</div>
</div>
</div>
<div class="content" id="main">
<div class="container">
<div id="primary" class="row content">
<?php
while ( $wp_query->have_posts() ) : $wp_query->the_post();
$postcount++ ?>
<article id="post-<?php the_ID(); ?>" class="col-lg-6 col-xs-12 front-page mb-5">
<?php if ( has_post_thumbnail() ) {?>
<div class="img-container">
<a class="read-more" href="<?php the_permalink($post->ID); ?>">
<figure class="wp-caption image">
<?php if ($postcount < 5 ) {
the_post_thumbnail( 'large', array( 'loading' => '' ) );
} else {
the_post_thumbnail( 'large', array( 'loading' => 'lazy' ) );
} ?>
</figure>
<div class="overlay">
<div class="text">
<h2><?php echo Excerpt::improvedExcerpt(the_title(), 5); ?></h2>
<?php the_excerpt(); ?>
</div>
</div>
</a>
</div>
<div class="d-flex justify-content-between bd-highlight mb-2">
<div class="p-2 bd-highlight">
<small><i class="fas fa-user"></i> <?php the_author(); ?></small>
</div>
<!--<div class="col-4 text-center">
<i class="fab fa-youtube"></i> <?php echo get_the_category( $id )[0]->name ?>
</div>-->
<div class="p-2 bd-highlight">
<small ><i class="far fa-clock"></i><time> <?php echo get_the_date(); ?><time></small>
</div>
</div>
<?php } ?>
</article>
<?php if ($postcount % 2 == 0 ) { ?>
</div><div class="row content">
<?php } ?>
<?php endwhile;
?></div><!-- .search-result-count -->
</div></div></div><div class="container">
<div class="row">
<div class="col-lg-12 col-xs-12 front-page mb-5"><nav class="d-flex justify-content-between bd-highlight mb-2" role="navigation">
<div class="p-2 bd-highlight"><?php next_posts_link( '<i class="fas fa-arrow-left"></i> Starsze posty' ); ?></div>
<div class="p-2 bd-highlight"><?php previous_posts_link( 'Nowsze posty <i class="fas fa-arrow-right"></i>' ); ?></div>
</nav>
</div>
</div><?php
} else {
?><div class="container">
<div class="row">
<div class="col-lg-12 col-xs-12"><?php
get_template_part( 'template-parts/content/content-none' );
?>
</div>
</div>
</div>
<?php
}
?>
</main>
<?php
get_footer();