Tag Info

New answers tagged

0

The Sphinx Search website lists three wordpress plugins on its Plugin Page. Maybe one (or more) of them does what you want? Voce Connect. Wordpress Plugin. Ivinco. Wordpress Plugin. Gigaom. Wordpress Plugin. Filters WordPress' core WP Query to allow interoperability with and improve performance of other plugins and existing queries, including core ...


0

The default "pretty" alternative to ?s= is /search/ - you should be able to use that right now. If you want to change it to student, add this to your functions.php file: function re_rewrite_rules() { global $wp_rewrite; $wp_rewrite->search_base = 'student'; } add_action('init', 're_rewrite_rules');


0

You can check if is_admin or not in the first line of the function add_filter('posts_where', 'advanced_search_query' ); function advanced_search_query( $where ) { if(is_admin()){ return $where; } if( is_search() ) { global $wpdb; $query = get_search_query(); $query = like_escape( $query ); // include ...


0

WooCommerce provides these kind of functionality. Some of the links which you can use as a reference WooCommerce Product Search


1

You need to use the user_search_columns filter to add the columns you want to search on. The user_search_columns filter is used to determine which user fields in the database are used when performing a search on user information. https://codex.wordpress.org/Plugin_API/Filter_Reference/user_search_columns


1

Just extend your search form with a hidden input: (notice the last input field) <form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>"> <label> <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span> <input type="search" ...


-1

You can usually specify the post type in WP_Query. Woocommerce is product Wordpress posts is post


1

This type of ordering is not available by default. You however have two basic options here rewind_posts() -> Rerun the loop multiple times and use rewind_posts() to rewind the loop so you can rerun it again EXAMPLE if ( have_posts() ) { while( have_posts() ) { the_post(); if ( $post->post_type == 'books' ) { // Output ...


0

It doesn't look like you're passing your search query in your WP_Query args. To do this on a custom search page try the following: Replace this: $the_query = new WP_Query('post_type=darpe-entries'); With this: global $query_string; $query_args = explode("&", $query_string); $search_query = array(); foreach($query_args as $key => $string) { ...


3

You can get close to what you want by using the template_redirect hook. function my_custom_search_url_rewrite() { if ( is_search() && ! empty( $_GET['s'] ) ) { wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) ); exit(); } } add_action( 'template_redirect', 'my_custom_search_url_rewrite' ); Then you can use a URL ...


1

You could use regular expression RLIKE: $val = '15'; $args = array( 'post_type' => 'shop', 'meta_query' => array( array( 'key' => 'map-location', 'value' => 's:7:"address";s:[0-9]+:"[^"]*' . preg_quote( $val ) . '[^"]*";', 'compare' => 'RLIKE' ), ) ); although it can fail if ...


0

I'm sure you've googled 'khabarnaak' - it's a Pakistani talk show. It's more likely to be an automated scraper trying to find content rather than an attack. The request does not look like it has been crafted for a Wordpress site. Two ways to stop it are: Block the IPs making the request. Add 'Deny from XX.XX.XX.XX' to your htaccess file, replacing ...


0

You can use meta query to search for a particular field text. $val = 'London'; $args = array( 'post_type' => 'shop', 'meta_query' => array( array( 'key' => 'map-location', 'value' => $val, 'compare' => 'LIKE' ), ) ); $query = new WP_Query($arg); Class Reference/WP Query


2

You need a meta_query something like this: $args = array( 'post_type' => 'shop', 'meta_query' => array( array( 'key' => 'map-location', 'value' => 'London', 'compare' => 'LIKE' // the = operator might work depending on how your data is stored ), ) ); Note: I am making some ...


0

Assuming that those users have accounts on your site (are subscribers, authors, or some other role), you can add custom fields to their profiles. The easiest way is to use a plugin, like Advanced Custom Fields (https://wordpress.org/plugins/advanced-custom-fields/). The fields would be available in their profile pages, and you can add, and use in any ...


0

Ok, the problem was with my radio buttons. <?php foreach( $regions as $region ) : ?> <label><input type="radio" name="region" value="<?php echo $region->slug;?>" /><span><?php echo $region->name;?></span></input></label><br /> <?php endforeach;?> I have solved this problem by giving ...


0

WordPress search only handles posts, it doesn't handle taxonomies and their terms ( tags, categories etc ) If you want more advanced search you'll have to use a 3rd party solution


0

Try going to your permalinks page within the admin to flush the rewrite rules. Just be navigating to that page will flush the rules, but you could click save even if you made no changes.


2

I think it is better that you switch to the current beta, version 2, publish on github. This version is much better in possibilities and performance. In this version it is possible that you get a result for the search term, Iike GET /wp-json/wp/v2/posts?s=awesome.


4

You need to place the following code in your theme's search.php file. <?php $search_query = get_search_query(); if ( $search_query == 'gold' ) { echo 'my gold ad'; } else if ( $search_query == 'oil' ) { echo 'my oil ad'; }


0

This works, when I put it in functions.php. function wpq_modify_search( $q ) { if ( ! is_admin() && $q->is_main_query() && $q->is_search() ) { $meta_query = [ 'relation' => 'or', [ 'key' => '_event_start_date', 'value' => current_time( 'mysql' ), ...


0

I got it ! Here is my final code for people who will search for similar problem :) in functions.php : function se190254_custom_sql_for_search( ) { global $wpdb; //For security escape the search parameter $search_string = esc_sql($_GET['s']); //Build the SQL request with $wpdb->base_prefix for "portability" $sql = "SELECT ...


0

I believe you need to setup the post data for each post. Try: $search_result = search_query_with_trips(); foreach( $search_result as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; You may need global $post before the foreach ...


1

jpd527, Please remember that 'tag' is singular and not plural. Here your form has multiple HTML element with same id so this is wrong. Now if you require to search data with two different inputs, then you can merge it via JS. HTML code like: <form method="get" id="search form" action="/"> <div> <input type="text" value="" name="tag_one" ...



Top 50 recent answers are included