How to search titles/artist/album within a playlist, and only lists the results that match?

I unhook the wp_underscore_playlist_templates() function and create my own version prefix_wp_underscore_playlist_templates() You should first get back to or restore the default playlist template. (i.e. Hook back to wp_underscore_playlist_templates().) Add then add this somewhere in the theme’s main functions.php file: add_action( ‘wp_playlist_scripts’, function(){ ?> <script> jQuery( function( $ ){ // Add the search box. $( ‘.wp-playlist’ … Read more

How to create custom search page

you dont need extra queries, all you would need is to sort the search results by post type. you can find a way to do so here. and then, inside your search.php template, you would need to check for the post-types and act accodringly.. while (have_posts()) : the_post(); $post_type = get_post_field( ‘post_type’, get_the_ID() ); if … Read more

How to trim white space in search terms?

I came across the same problem. In my opinion, this should be the default search behavior in WP. The solution is to filter the array of parsed query variables. See the documentation here. Add this to the functions.php file in your theme directory. add_filter(‘request’, function ($query_vars) { if (!is_admin() && !empty($query_vars[‘s’])) { $query_vars[‘s’] = trim($query_vars[‘s’]); … Read more

Search transients through widget

A. This is a good idea in general? I’m quite new to transients. No, not really. If your data is for display and search then it’s not really ‘transient’, is it? You should store the data properly in a more permanent place and periodically sync it. If the data from this API makes sense as … Read more

Slow Query On Search

This is the query generated by the internal search function on WordPress. It is criticised for being inefficient, and there are a few drop-in replacements available as plugins. You may be able to find something that helps you by doing more research around these. For example: https://themeisle.com/blog/improve-internal-search-in-wordpress/ https://winningwp.com/best-wordpress-search-plugins/ I don’t have a specific recommendation to … Read more

How do you determine if a result in a search query is a post or a page?

That will only tell you if it’s a Post or a Page. What if it’s a category, tag, archive, or custom post type? Here’s how I’d write that, if you care. function xyz_get_post_type_name() { $wp_type = get_post_type( get_the_ID() ); switch ($wp_type) { case ‘post’ : $type_name=”Article”; break; case ‘page’ : $type_name=”Web Page”; break; case ‘quote’ … Read more

Sort WP Search results by date

@KA.MVP You can create hidden fields for ‘orderby’ and ‘order’ with default values ‘post_date’ and ‘desc’ or ‘asc’ in it, you can also put this form inside add_shortcode function explained below and use wherever you want to use by adding shortcode [custom_search_form] function search_form_func() { ?> <form method=”get” action=”https://www.example.com/” id=”sv2″> <input name=”s” id=”s” size=”30″ title=”Search … Read more