File: /var/www/iprojectlab.com/laracopilot-wp/wp-content/themes/laracopilot/search.php
<?php
/**
* The template for displaying search results pages
*
* @package LaraCopilot
* @version 1.0.0
*/
get_header(); ?>
<div class="min-h-screen pt-20">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<!-- Search Header -->
<header class="text-center mb-16">
<h1 class="text-4xl sm:text-5xl font-bold text-white mb-6">
<?php
if (have_posts()) {
printf('Search Results for: "%s"', get_search_query());
} else {
printf('No Results for: "%s"', get_search_query());
}
?>
</h1>
<div class="max-w-md mx-auto">
<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>" class="flex">
<input type="search" name="s" value="<?php echo get_search_query(); ?>" placeholder="Search..." class="flex-1 px-4 py-3 bg-black/50 border border-red-500/30 rounded-l-lg text-white placeholder-gray-400 focus:outline-none focus:border-red-500">
<button type="submit" class="px-6 py-3 bg-red-600 text-white rounded-r-lg hover:bg-red-700 transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
</svg>
</button>
</form>
</div>
</header>
<!-- Search Results -->
<?php if (have_posts()) : ?>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('group bg-black/40 backdrop-blur-sm border border-red-500/20 rounded-2xl overflow-hidden hover:border-red-500/40 transition-all duration-300 hover:transform hover:scale-105'); ?>>
<?php if (has_post_thumbnail()) : ?>
<div class="aspect-video overflow-hidden">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('laracopilot-feature', array('class' => 'w-full h-full object-cover group-hover:scale-110 transition-transform duration-300')); ?>
</a>
</div>
<?php else : ?>
<div class="aspect-video bg-gradient-to-br from-red-500/20 to-red-700/20 flex items-center justify-center">
<a href="<?php the_permalink(); ?>" class="text-center">
<svg class="w-12 h-12 text-red-400 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"></path>
</svg>
<span class="text-red-400 text-sm">Read More</span>
</a>
</div>
<?php endif; ?>
<div class="p-6">
<div class="flex items-center text-sm text-gray-400 mb-3">
<time datetime="<?php echo get_the_date('c'); ?>"><?php echo get_the_date(); ?></time>
<span class="mx-2">•</span>
<span><?php the_author(); ?></span>
<?php if (get_post_type() !== 'post') : ?>
<span class="mx-2">•</span>
<span class="bg-red-500/20 text-red-400 px-2 py-1 rounded text-xs"><?php echo get_post_type(); ?></span>
<?php endif; ?>
</div>
<h2 class="text-xl font-semibold text-white mb-3 group-hover:text-red-400 transition-colors duration-300">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<p class="text-gray-300 leading-relaxed mb-4">
<?php echo wp_trim_words(get_the_excerpt(), 15, '...'); ?>
</p>
<a href="<?php the_permalink(); ?>" class="inline-flex items-center text-red-400 hover:text-red-300 transition-colors duration-300">
Read More
<svg class="ml-2 w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"></path>
</svg>
</a>
</div>
</article>
<?php endwhile; ?>
</div>
<!-- Pagination -->
<div class="mt-12 flex justify-center">
<?php
the_posts_pagination(array(
'mid_size' => 2,
'prev_text' => '<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg> Previous',
'next_text' => 'Next <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>',
'class' => 'pagination',
));
?>
</div>
<?php else : ?>
<div class="text-center py-12">
<svg class="w-16 h-16 text-gray-400 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
</svg>
<h3 class="text-xl font-semibold text-white mb-2">No results found</h3>
<p class="text-gray-400 mb-8">Sorry, no posts matched your search criteria. Try different keywords.</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<a href="<?php echo esc_url(home_url('/')); ?>" class="inline-flex items-center justify-center px-6 py-3 text-white bg-red-600 rounded-lg hover:bg-red-700 transition-colors">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
</svg>
Go Home
</a>
<a href="<?php echo esc_url(home_url('/blog')); ?>" class="inline-flex items-center justify-center px-6 py-3 text-white border-2 border-red-500/50 rounded-lg hover:border-red-500 hover:bg-red-500/10 transition-colors">
Browse All Posts
</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>