For creating live search just need send a GET request to wp-json
no need to make a new query
just use this URL in ajax request:
<?php echo get_site_url(); ?>wp-json/wp/v2/posts?search=' + GetSearch.value
So ajax code should be like this:
<script> var GetSearch = document.getElementById('search'); GetSearch.addEventListener("keyup", function(){ //InfoData = {slug:GetSearch.value} $.ajax({ type: "GET", url: '<?php echo get_site_url(); ?>wp-json/wp/v2/posts?search=' + GetSearch.value , data: '', datatype: "html", success: function(result) { console.log(result); } }); }); </script>
and the HTML search input should be like this:
<input type="search" id="search" name="search" placeholder="search" autocomplete="off"/>
you must turn off the autocomplete of input
Related Posts:
- Redirect after Login on WordPress
- WordPress Email Share button not opening in Outlook
- Divi Child Theme Breaks WordPress Customizer
- WordPress- url for localhost wp-admin is not working
- WordPress- url for localhost wp-admin is not working
- Muffin Builder has a limit? (WordPress – Be Theme)
- How to correctly use get_template_directory_uri() WordPress function to load an image that is in a subfolder of my theme?
- Correct way of using wp_get_attachment_image() in wordpress
- PHP fopen() Error: failed to open stream: Permission denied
- The requested URL /about was not found on this server
- CSS background images in WordPress
- Formidable Forms WordPress Plugin
- How to implement inline cm/inches conversion in WordPress
- How to remove unwanted space in wordpress OMG Blog theme?
- Redirect old php link to wordpress link in .htaccess
- WordPress qw.php file on root of installation
- How to change thumbnails for WordPress pages (KakaoTalk)
- How to convert JPG to PNG on upload in WordPress (via add_image_size)?
- WordPress asking for my FTP credentials to install plugins
- WordPress asking for my FTP credentials to install plugins
- WordPress plugin install: Could not create directory
- WordPress makes an auto-draft as soon as I enter the page
- Using WordPress on 000webhost.com
- Add CashU payment gateway to WordPress Woocommerce
- WordPress custom thumbnail size
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Local WordPress installation is stripping ‘wp-admin’ from URL on WordPress admin dashboard
- Advanced Custom Fields, Yoast SEO, not updating new values in WordPress
- WordPress sort WP ULike posts in custom query?
- In WordPress Using Elegant Theme’s Divi Theme, Long menus don’t show
- Exclude Featured Posts in WordPress ‘Recent Posts’ Function
- WordPress: How to overlay text / widget div on top of a revolution slider
- Find source of Google Fonts in WordPress
- WordPress – add second logo to customizer
- php, cookies, wordpress – how to make automatic login in one one site, login and on other one
- How can I removed Powered by WordPress link in wp.login.php without editing core WP files?
- WordPress Login Tracking Google Analytics
- Astra Pro theme for WordPress why isn’t logo showing?
- WordPress – Check if user is logged in
- WordPress custom supports for custom post types
- WordPress PHP proxy/helper pages for Twitter API
- How to enable button onClick functions and java script in wordpress post
- Marathi typing option in wordpress Editor
- WordPress: Loading multiple scripts with enqueue
- WordPress: Loading multiple scripts with enqueue
- Display all post meta keys and meta values of the same post ID in wordpress
- Query multiple WordPress post types alternately
- How to add custom javascript to WordPress Admin?
- With “magic quotes” disabled, why does PHP/WordPress continue to auto-escape my POST data?
- After moving WordPress, login works, but no admin access anymore
- WordPress localhost not working
- validate textfield contents in wordpress simple job board plugin
- wordpress Simple Job board plugin hide cv attachment form
- How can I access http://localhost/wordpress/wp-admin/install.php?
- How can I access http://localhost/wordpress/wp-admin/install.php?
- WP_Query(‘orderby=post_date’) not working with wordpress
- Dash icons Not Showing properly in Menu Using WordPress
- W3 Total Cache WordPress plugin disturbing my page layout
- WordPress Error: There has been a critical error on your website. Please check your site admin email inbox for instructions
- No paged query var being set in WordPress custom pagination
- cannot change admin password, wordpress on godaddy
- WordPress Password Protected Page is not protected
- How do i give a WordPress editor access to the Site Kit by Google plugin?
- How to find HTML rendered by in WordPress?
- Local wordpress install only shows home page, all other pages Not Found
- Permalinks in WordPress not working
- cannot change admin password, wordpress on godaddy
- cannot change admin password, wordpress on godaddy
- how to add gravity forms to blog page(posts page) in WordPress
- Oxygen Builder with theme in WordPress
- How to define custom capabilities in wordpress for custom plugin
- WordPress Order by date on custom post type archive page
- WordPress Salient theme: getting a full width 2 columns portfolio
- Get the WordPress attachment image url
- Prevent category updates in WordPress Woocommerce REST API
- Double slashes on WordPress Admin URL redirects to wp-login
- wordpress login wp-login.php change url
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- WordPress (GoDaddy: Linux w/cPanel (Apache))_ My 2nd site is FUBAR__ subdomain multisite network installation
- Display Ninja Forms Data in WordPress Template
- WordPress “Save Draft” fails: “the response is not a valid JSON response”
- update post meta wordpress
- Get Categories of events in WordPress Events Calendar Pro Plugin
- Get Categories of events in WordPress Events Calendar Pro Plugin
- How can I add a PHP page to WordPress?
- Adding style.css in wordpress, the correct way
- Where to start in the WordPress codex?
- Problem getting data with WooCommerce/WordPress
- WordPress get_template_directory_uri() not returning https and only return http
- Display all post meta keys and meta values of the same post ID in wordpress
- How can I configure the WordPress development environment locally?
- Error establishing a database connection in my localhost
- function “add_submenu_page in wordpress connects to the home page instead of the submenu page
- Add php code inside the function add_shortcode in functions.php WordPress
- How to cache/speed WordPress queries for logged in users?
- Show comments on WordPress home page
- How to easily add cropped screenshot to self-hosted WordPress as hosted image?
- Which ways can be used to log in to WordPress?