admin管理员组

文章数量:1391960

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.

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.

Share Improve this question asked Mar 11, 2020 at 18:49 JuliaJulia 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1
  1. 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(); ?>
  1. Save the file.

  2. Upload the file to your theme directory (if you made changes to your style.css style sheet file, upload that, too).

  3. 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

本文标签: WordPress Custom Pages that work with Plugins