Forums

how to include searchform.php (8 posts)

  1. solidcolour
    Member
    Posted 2 years ago #

    This is php question really.
    I can put <?php include (TEMPLATEPATH . '/searchform.php'); ?> into any template, but how can i put it into "here"? <?php else : here endif; ?>

    Thanks

  2. peterwongpp
    Member
    Posted 2 years ago #

    <?php else: include(TEMPLATEPATH . '/searchform.php'); ?>

    is this ok?

  3. solidcolour
    Member
    Posted 2 years ago #

    yes it works, i was thinking that as well just want to make sure.

    thanks

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    The "correct" method is to use <?php get_search_form();?>,

  5. solidcolour
    Member
    Posted 2 years ago #

    you are right esmi, but we may want to custom it for the styling.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    How does that affect using the correct WP function/tag? Just create your own searchform.php template file, add it to your theme and <?php get_search_form();?> will call it automatically. I've not created a theme yet that uses the default search form.

  7. solidcolour
    Member
    Posted 2 years ago #

    thnanks esmi, that was beautiful!

  8. solidcolour
    Member
    Posted 2 years ago #

    Here I found another issue:

    What if the <?php get_search_form();?> has been used 2 times on a page (e.g. the hform not only in sidebar but also in main content in 404.php)

    So, there will be problems with the ID tags, W3C doesn't allow using a same ID name more than 1 time on a page.

    I can copy the code from searchform.php and give some new ID names but it's not so convenient if add it to few pages.

    Any better solution please?

Topic Closed

This topic has been closed to new replies.

About this Topic