Very Basic Search Results Page (WordPress)

<?php /* Template Name: Very Basic Search Results Page */ ?> <?php get_header(); ?> <!-- begin body content --> <main role="main"> <?php if (have_posts()) : ?> <h1>Search results for: <span><?php echo get_search_query(); ?></span></h1> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <hr> <?php endwhile; ?> <?php else : ?> <p>Sorry, no results were found.</p> <?php endif; ?> </main><!-- /body content --> <?php get_footer(); ?>
Save as search.php

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.