How to make a search form?

When you code get_search_form() WP search searchform.php in your theme root and print all inside that file. And you can create searchform.php inside your theme root and insert this: <form role=”search” method=”get” action=”<?php echo home_url(“https://wordpress.stackexchange.com/”); ?>”> <fieldset> <input type=”text” name=”s” value=”<?php the_search_query(); ?>”> <button></button> </fieldset> </form> That basic search form. Then code <?php get_search_form() ?> … Read more

Changing search slug from + to – (hyphen)

PHP’s urlencode() function replaces spaces with +s, so that’s why that’s happening for you. WordPress provides the sanitize_title() function, which is used (among other things) to generate a post slug from the post’s title. /** * Change search page slug. */ function wp_change_search_url() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { wp_redirect( … Read more

How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?

it adds additional value before and after each Like query That {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is a placeholder escape string for the literal % (percent) sign used in prepared statements (see wpdb::prepare()) and the escape string is generated by wpdb::placeholder_escape(). So actually, that {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is the % sign, but in an escaped form, and it will be changed … Read more

Creating a “Tags” page with search option, instead of using a widget

Create a file in your theme called for example : myTagsPage.php in it paste the following code <?php /* Template Name: myTagsPage */ <h2>Actors</h2> <?php the_tags(‘<ul><li>’,'</li><li>’,'</li></ul>’); ?> ?> then in administration, create a new blank page, on the right side, you should be able to choose which template you want – pick myTagsPage you can … Read more

Search in Two Categories

Basically you don’t really want search, but separate page that will list post on specific condition? You can create template for a page with Loop that will query for posts, belonging to both categories, using category__and parameter.

What causes an Unexpected HTTP Error within install plugins?

You can use the following code to dump the HTTP Api response, will help you figure out the cause of error. function dump_http_api_response($response, $type=””, $transport=null ) { if ( $type == “response” ) var_dump ( $response ); } add_action(‘http_api_debug’, ‘dump_http_api_response’, 1, 3); Example Output: object(WP_Error)#15 (2) { [“errors”]=> array(1) { [“http_request_failed”]=> array(1) { [0]=> string(41) … Read more

Differentiate between posts and pages in search results

Try this… <?php //prevent this div from displaying for pages: if ( get_post_type() != ‘page’ ) : ?> <div class=”searchdate”><?php the_time(‘F jS, Y’) ?></div> <?php endif; ?> The is_page() conditional tag only checks if currently displayed content is a single page view. Nothing for you at this point. See http://codex.wordpress.org/Function_Reference/is_page

Varying Search Result Pages

you can add an hidden filed to your search form and include a different template based on that: <form role=”search” method=”get” id=”searchsupport” action=”https://wordpress.stackexchange.com/”> <label class=”screen-reader-text” for=”s”>Search for:</label> <input type=”text” onfocus=”if (this.value == ‘Search’) {this.value=””;}” onblur=”if (this.value == ”) {this.value=”search”;}” id=”s” name=”s” value=”search” class=”search-form round”> <input type=”hidden” id=”searchsubmit”> <!– this is the magic field —> <input … Read more

Refine search results using WP_Query

You need to just merge the current query for the search with the part you want to add which you came close to doing already. I assume you have a custom taxonomy called media and you specifically want to leave out posts with the term media (like a term found in a tag or category) … Read more