• I want to do something that is beyond my current knowledge. I’m building a site that has TNG (a genealogy database) in a subdirectory. This uses a template with a search box that sends the user to a particular page.

    I’ve built a test site and you can see the search box here If you try it with John Lewis as the names, when the user clicks on search it displays https://test-lewis.one-name.net/tng/search.php?myfirstname=John&mylastname=Lewis&mybool=AND

    I want to put a similar search box on the home page of the main site https://test-lewis.one-name.net, either on the page itself or preferably in a widget. I don’t have any PHP knowledge but was a programmer many moons ago so could probably manage to do it with guidance. But I really don’t know where to start. Can anyone point me in the right direction please?

    Thank you – Melody

    • This topic was modified 3 years, 7 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    You just need to copy that form on your test page to the homepage of the main site.

    <form method="get" name="searchform" action="search.php" class="entry-content" id="home-search-box">...
    </form>

    And change the styles you want.

    Hi @melodyingreece,

    First of all, you need to create a search.php page which is equal to the directory in your website

    Here is the code frame for the search.php page:

    <div id="searchResults">               
                                            <?php if(have_posts()) : while(have_posts()) : the_post() ?>
                                            <div class="search">
                                            
                                                    <div class="post">                                                                        
                                                    <div class="post-image">                                                                        
                                                            <a href="<?php echo the_permalink(); ?>" title="<?php the_title(); ?>">
                                                              <?php the_post_thumbnail(); ?>
                                                            </a>
                                                    </div>
                                                    <div class="post-info">
                                                            <a href="<?php echo the_permalink(); ?>" title="<?php the_title(); ?>"><h3><?php the_title(); ?></h3></a>
                                                            <div class="location">submission date: <i><?php the_time('d/m/Y'); ?></i>, Update: <?php the_modified_time('d/m/Y'); ?> at: <?php the_modified_time(); ?> </div>
                                                            <p><?php the_excerpt(); ?> </p>
                                                    </div>
                                                    </div>
                                                    
                                                    
                                            </div>
                                            <?php endwhile; else: ?>
                                            <p>The keyword is not found please try again.</p>
                                            <?php endif; ?>
                                    </div>

    Here is the code frame for the search form:

    <div class ="search-right">
            <form action="<?php echo get_home_url(); ?>/" method="get">
                    <input type="text" id="s" name="s" class="form-control" value="" placeholder="What do you want to search for?">
                    <button type="submit" class ="search-news">Find now</button>
            </form>
    </div>

    Let me know if my answer can help you resolve your issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add a search that will send visitors to a URL’ is closed to new replies.