WordPress search form and input type=”image”

You have to use javascript or jQuery for this form. You can use like this: <!– Custom Style for the form –> <style type=”text/css”> body { margin: 0; padding: 30px 0; font-family: arial; font-size: 16px; line-height: 22px; max-width: 800px; margin: 0 auto; overflow: hidden; } body:after { content: ”; clear: both; display: table; } img{ … Read more

Search redirects to index

The problem was due to htaccess file that was in the root directory. **`.htaccess`** DirectoryIndex start.php This was causing all of the index.php files to be changed to start.php. This filr did not exist in my wordpress directory. When I renamed the index.php to start.php in the wordpress installed sub directory the search started to … Read more

Search query with quotes

using the \’ escape works for me, so whatever is causing your issue is something else with your website. I checked with the code below: $the_query = new WP_Query( [‘post_type’ => ‘post’, ‘s’ => ‘Hello\’s’] ); if ( $the_query->have_posts() ) { echo ‘<ul>’; while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; … Read more

Search results: How to add direct jump to anchor?

You should have the navigation menu with anchors on your page. <ol> <li><a href=”#products”>Products</a></li> <li><a href=”#examples”>Example</a></li> </ol> And the sections with relevant ID where are these anchors are linked to. <h2 id=”products”>Products</h2> After the changes are done, ask google to reindex your page and wait=) Here is detailed description: here

Listing parent section in search results

For your custom post types and your blog, you can use get_post_type(). For your About parent page, if the pages only go one level deep, you can check $post->post_parent to see if it’s the about page. Otherwise, you can use get_post_ancestors() and check that array to see if your About page is in it!

Strip the + symbol from the_search_query

Personally, when I do things like this I use str_replace() [Link] Using your above example it would be implemented like so: <?php $string = the_search_query(); $res = str_replace(“+”, ” “, $string); echo $res; ?> That will replace any + with a space. Or if you want the &nbsp; use this: <?php $string = the_search_query(); $res … Read more

SQL: Search query to get attachments only of those parents which are published

Well since nobody helped with at first look such an easy problem, i used my way, and if somebody will need it here it is: I used this query: $results = $wpdb->get_results( $wpdb->prepare( “select $wpdb->posts.ID, $wpdb->posts.post_status, $wpdb->posts.post_parent from $wpdb->posts where post_title like ‘%%%s%%’ and (post_type=”albumas” OR post_mime_type=”audio/mpeg”) AND (post_status=”inherit” OR post_status=”publish”) $excludes limit 0,”.$setting->limit, ($setting->search_content … Read more