I'm trying to create a search page for my custom site. I'm having a hard time creating custom pages in my plugin code. I want the plugin to create pages at a custom URL that work with each other; for example a /search page that automatically exists within the plugin contents and then workable links afterwards. Any help would be greatly appreciated.
1 Answer
- Create a Search Page Template
- If you do not have a page.php, you can create one based upon your Theme’s index.php template file.
Note: The filename search.php is reserved as a special template name, so avoid its usage; the suggested searchpage.php just makes it easy to recognize in the list of files
-At the top of your searchpage.php, before anything else, add this to give your Search Page a heading WordPress will recognize in the Administration Screens:
<?php
/**
* Template Name: Search Page
*/
?>
<?php get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php get_search_form(); ?>
</main>
</div>
</div>
<?php get_footer(); ?>
Save the file.
Upload the file to your theme directory (if you made changes to your style.css style sheet file, upload that, too).
Create new page in admin side and assign search page template in the page
get_search_form();
-Above function is default Search form function of wordpress