How to make the WP query search for the “s” arg in other places too
How to make the WP query search for the “s” arg in other places too
How to make the WP query search for the “s” arg in other places too
since in the comments you explained by dynamically you mean without reloading/refreshing the page. the answer to the first question is: yes, you will use AJAX calls. first, create the search input <input name=”input_name” placeholder=”<?php echo __(‘search’,’textdomain’); ?>”> second, the Javascript registered and enqueued script in functions.php (function ($) { $(document).ready(function () { $(“[name=input_name]”).keyup(function () … Read more
You need to be reading the search parameter from the URL. By default WordPress uses the parameter s to store the search results. So you’d need to do something like: $user_search = ( isset( $_REQUEST[‘s’] ) ? ‘*’ . wp_unslash( trim( $_REQUEST[‘s’] ) ) . ‘*’ : false ); if ( false != $user_search ) … Read more
Use get_userdata() to get a user object, and the email address will be the email property: $userdata = get_userdata( $user_id ); if ( ! $userdata ) { return false; } echo $userdata->email;
Use the below code it may help you and sure that your sql query is correct then it will be work properly. function wpb_demo_shortcode() { global $wpdb; $results = $wpdb->get_results( $wpdb->prepare(“SELECT DISTINCT o.order_id, o.`order_item_name`, om.`meta_value` as ‘bcs’, (select pm.`meta_value` from `wp_postmeta` as pm WHERE o.order_item_id = om.order_item_id AND pm.`post_id` = o.order_id AND pm.`meta_key` = ‘2-certificate’) … Read more
After further investigation, I noticed my theme was actually replacing all the anchor tags with shortcodes for SEO purposes, so there weren’t any links in the content anymore. I was able to make it work by replacing $content = get_the_content(); with $content = apply_filters( ‘the_content’, get_the_content() );
Custom database table and custom search
Isn’t that just because you’ve put ! empty( $_GET[‘s’] ) in your IF statement? Is your search page accessible when you remove that part? EDIT: Or maybe change your function to something like this (untested): function wpb_change_search_url() { if ( is_search() ) { if ( isset( $_GET[‘s’] ) ) { wp_redirect( home_url( “/search/” ) . … Read more
First you need to edit your searchform.php file. If you are using get_search_form(); read this . In case you use search widget you need to override the Widget. If you dont want to use searchform.php you can go with filter: function wpdocs_my_search_form( $form ) { $form = ‘<form role=”search” method=”get” id=”searchform” class=”searchform” action=”‘ . home_url( … Read more
Try this one: Just add the function in your theme functions file and then in your (search) template, add echo get_query_terms_list(); to display the terms list. But do take note, this is intended only for the current search results, i.e. on the same page. function get_query_terms_list( $taxonomy = ‘post_tag’, $sep = ‘, ‘ ) { … Read more