WordPress Search results Programmatically

I want to include an automatic search results output on my 404 page based on the url that the user has type in.

The problem is that on the usual search.php file, wordpress gets the value from the URL parameter and uses the regular loop like so:

Read More
 <?php while (have_posts()) : the_post(); ?>
   <h1>Search Results</h1>
   <a href="<?php the_permalink() ?>"> <h2><?php the_title(); ?></h2> </a>
 <?php endwhile; ?>

How do I get it so that I can manually enter the search term in the code?

Much appreciated.

Related posts

Leave a Reply

1 comment