WP Search Form Query: Add Author's posts into search query

As the title suggests, I'm looking for WordPress advice relative to leveraging the standard searchform.php functionality to additionally query the author field when performing searches. I've tried various different means to do this without any success, and so I'm coming to quite the headache. Below are the template files used: searchform.php <?php /** * Template for displaying search forms in Twenty Seventeen * * @package WordPress * @subpackage Twenty_Seventeen * @since 1.0 * @version 1.0 */ ?> <?php $unique_id = …
Category: Web

Custom search: Search posts but display parent page in results

I'm using Wordpress 3.5.1 with a modified twentytwelve theme. My main site structure is based on the Smooth Slider plugin (jQuery Cycle). I have Pages that contain only a shortcode (for example, [smoothslider id='4']) to display Posts assigned to a slider. When I do a search on the site it returns result for individual posts only (and not for pages, of course). This is not what I want as there is no slider anymore. Those posts are not supposed to …
Category: Web

Conditional tag search-no-results

Is there a way to make a conditional tag that tests if it is search-no-results page? I know that there is a function to check if is_search() page: if(is_search()){ echo "search page"; } But I didn't found a way to check for search-no-results, and I noticed that WordPress gives body class with search-no-results to this page.
Category: Web

search.php to search only the post title

I'm trying to rewrite my search.php to search only for the post titles because I have a ton of posts published to my site (around 400k), which slows down the search speed to about 20s per search. <?php get_header(); $search_term = $_GET['s']; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $posts = new WP_Query( array( 's' => "$search_term", 'ep_integrate' => true, 'post_type' => 'post', 'posts_per_page' => 21, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, ) ); ?> <?php if …
Category: Web

Show matching categories in search page

my current search only shows POSTS as results. http://newslines.org/?s=george My site has categories for George Clooney, George R.R. Martin etc. How do I get a list of categories that match the search term to show at the top of the results page? I have tried this: <?php $search_query = get_search_query(); $term = get_term_by( 'name', $search_query, 'category' ); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ echo "<ul>"; foreach ( $terms as $term ) { echo "<li>" . $term->name …
Category: Web

Include results with tags relevant to the search keyword with JSON rest API v2

Wordpress doesn't natively search for tags so I need to install WP Extended Search and add post_tags as one of its parameters so whenever I search for keywords natively, posts with that tag will appear. However, when I tried searching on the wp-json REST API, that post doesn't appear. Here's an example with a post that is tagged with "technology". When I search "technology " using this json rest api url, it returns an empty array: example.com/posts?search=technology But if I …
Category: Web

Search not showing all results

EDIT: So I've done some troubleshooting and it seems my theme isn't showing woocommerce search results. The 2017 theme does so I am trying to figure out what my theme is missing. I suspect something in the functions.php file. It's something I'm leaving out, not something I've included that's interfering, because I deleted all my code out of the functions file line by line and nothing changed. I have some custom code I have used elsewhere without any trouble. I …
Category: Web

Highlight search words in excerpt

I have designed and developed a responsive Wordpress site that is almost ready for launch for a client who is an actor and producer. I have been stuck on my requirements for the search results page for three days. My EXCERPT is far too long and includes repeated text from the Home page no matter what the search is for. Under the white links to the posts and pages for the search results, I want an excerpt of no more …
Category: Web

Create custom query for search?

I have create search box using ajax.If i enter any value in search input box that this value search in post title or post meta data and get all data of this value in custom post type.also query check only post title and specific post meta data. Not check in Post content or any other field. I have tried this query $args = array( 's' => $keyword, 'numberposts' => -1, 'post_type' => 'store', 'meta_query' => array( 'relation' => 'OR', array( …
Category: Web

Searchable database of members using multiple criteria / filters

I'm very new to wp let's say that first! What I need is to create a site which will list a database of members of an organisation. Users will also be able to sign-up and add themselves to the database. But additionally I want users to be able to search for other users using given criteria check boxes, for example: Is male [ ] Is female [ ] Lives in city x [ ] Lives in city y [ ] …
Category: Web

How to Implement Search Functionality?

<div class="col-lg-8"> <div class="row"> <?php $search_term = get_search_query(); $term = get_term_by('slug', $search_term, 'blog_taxonomy'); $term_name = $term->name; $args = array( 'post_type' => 'blog', // 'title' => $search_term, 'tax_query' => array( array( 'taxonomy' => 'blog_taxonomy', 'field' => 'slug', 'terms' => $search_term, 'orderby' => array( 'date' => 'DESC', ), ), ), ); $loop = new WP_Query($args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); ?> <div class="col-lg-6 col-md-6"> <div class="blog-content radius30 cB-shadow cBorder mw-100"> <div class="blog-img text-center position-relative"> <div class="date-time position-absolute"> <div class="date"> <h6><?php …
Category: Web

Display full WordPress post under search form using AJAX

Hi I am currently creating a site that shows interactions between different pharmaceutical drugs. I originally started with Live search on JSON Objects Data Using jQuery (originally based on this article: https://www.js-tutorials.com/jquery-tutorials/live-search-json-objects-data-using-jquery/ but modified slightly below) however the client must be able to add constant content and a JSON file was too difficult for them to edit. I am now creating a page for each drug as a WordPress post (and perhaps use a tag to distinguish it for search) …
Category: Web

Custom Search Query – include only custom fields and title

I have a custom post type and I also need a custom search. I want the post title and two custom fields to be indexed/queried. I found solutions for title only and for custom fields but not for both so I tried to combine. Why doesn't this work? function custom_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing - no search term in query $q = $wp_query->query_vars; $n = ! empty( …
Category: Web

How to Fix Form elements do not have associated labels in Wordpress Search Form (without button)

Is there any way to fix the "Form elements do not have associated labels" issue in WordPress search form without having the search button. Google Light House Audit: Form elements do not have associated labels. Labels ensure that form controls are announced properly by assistive technologies, like screen readers. Failing Elements input <input type="text" value="Search" name="s" id="psf" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}"> I want to add a label in the form …
Category: Web

What is the logic/algorithm behind 'did you mean' suggestion by search engines, command suggestion in command prompt like git?

For eg. https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work this is the logic behind google's did you mean algorithm - used for spell correction suggestion. What is the algorithm used in case of other search algorithm for spell correction/ to find similar text - in case of a music/OTT search app, eg. amazon music - Similarly - what is the logic used - in case of git commands - How do one usually backtrack the algorithm behind an application from usage? Any general ideas will also …
Category: Data Science

how can I override The Events Calendar query modifications?

I am implementing some special search options that should exclude anything not of the type post. The Events Calendar is interfering and modifying the query on the fly anyway. My query mod just looks like: $query->post_type And I am doing this before the query in question: remove_action( 'pre_get_posts', [ 'Tribe__Events__Query', 'pre_get_posts' ], 50 ); remove_action( 'parse_query', [ 'Tribe__Events__Query', 'parse_query' ], 50 ); ...and restoring the actions afterward to resume normal operation. So with this debug code: add_filter('query', function($sql) { global …
Category: Web

Using search.php without a 's' field in searchform.php

Sorry if this is a simple/daft question but I'm still getting to grips with how WordPress search functions. I want to completely replace the standard search within my template with a custom search that only queries a certain custom post type and its meta fields. I have a search form which does this and search.php which returns the correct data. However, the search will not function unless I include a input field named 's' and it is not empty. I …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.