two search forms on the same page

The get_search_form function doesn’t work like that. The parameter that is accepted only specifies if the HTML content is being returned or outputted directly. So this parameter should be a boolean. It still works in your case because PHP simply evaluates the string that you are passing as true considering that it is not an … Read more

Can’t load search results with ajax

The JavaScript should be: <script> jQuery( document ).ready(function ( $ ) { $( “#searchform” ).on( “submit”, function ( ev ) { ev.preventDefault(); $.post( “<?php echo admin_url( ‘admin-ajax.php’ ) ?>”, { action: “wpa56343_search”, search: $( “#s” ).val() }, function ( response ) { $( “body” ).append( response ); } ); }); }); </script> And the AJAX … Read more

Make archive page show up in search results?

The issue is that an archive isn’t a post, it’s not something that can be shown in the loop. On your search results page, you’ll have to add some code to search categories for a similar name. You can accomplish this with the generic get_terms. Pass the searched term as the name__like argument (or maybe … Read more

Live search from database table

So in php it needs to be: $query = ‘SELECT Location FROM locations’; $result = mysqli_query($link, $query); $rows = array(); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r[‘Location’]; } and jquery ui autocomplete: $(“#location1”).autocomplete({ source: <?php echo json_encode($rows);?>, // this part is only if you want to force autocomplete select change: function (event, ui) { if(!ui.item){ … Read more

Search only working on front page (index) , not working on other pages

Currently your form looks like: <form id=”search-query”> <p class=”in-english”><a href=”http://localhost/hermodswp/?page_id=76″>Information in English</a></p> <div class=”search-box”> <div> <label class=”screen-reader-text” for=”s”></label> <input type=”text” value=”sdf” name=”s” id=”s” style=”width: 293px;”> <input type=”submit” id=”searchsubmit” value=”Sök”> </div> </div> </form> Try adjusting your submit action to point to your home_url(). action=”<?php echo home_url(); ?>” You can edit the page in Chrome to see … Read more

Display Search Results after search 1st link

Redirecting to the first result of a search is a very unfriendly thing to do to your visitors and can quite possibly prevent them from ever finding the content they need, but it is very easy to do: function redir_first_wpse_49208() { if (is_search()) { global $wp_query; if (!empty($wp_query->posts)) { wp_redirect( get_permalink( $wp_query->posts[‘0’]->ID ) ); exit; … Read more