Search Results
Infinite scroll search results with Ajax Load More
In this example:
Ajax Load More will search content based on keyword value using the Search query parameter.
Ajax Load More offers free extensions that integrate with the popular WordPress search plugins SearchWP and Relevanssi.
Did You Know: The Filters add-on provides a text input filter to easily render and display search results with Ajax Load More – View Example.
The following code should be placed inside a page template where you render Ajax Load More.
<?php
$term = is_search() ? get_search_query() : $_GET['term']; // get search query or `term` from query string.
if ( empty( $term ) ){
$term = 'WordPress';
}
echo do_shortcode( '[ajax_load_more post_type="post, page" search="' . esc_attr( $term ) . '" orderby="relevance"]' );
PHPYour search for "WordPress" returned the following results:
-
WordPress Plugin Installer
An open source PHP class for installing and activating WordPress plugins.
-
How to Add Infinite Scroll to WordPress with Ajax Load More
A (non) definitive guide to a painless implementation.
-
Introducing Instant Images for WordPress
One click image uploads from Unsplash to your media library.
-
Infinite Scrolling with the WordPress REST API
Introducing a RESTful API extension for Ajax Load More.
-
Infinite Scroll Your WordPress Single Posts
Introducing our latest Ajax Load More add-on, Previous Post.
The following shortcode was used to create the Search Results example.
[ajax_load_more preloaded="true" preloaded_amount="3" posts_per_page="3" search="' . $term . '" orderby="relevance"]
Variables are being passed into this Ajax Load More shortcode using theĀ do_shortcode method.
The following Repeater Template was used to create the Search Results example.