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 parameter.
Did You Know: Ajax Load More offers extensions to integrate with the popular WordPress search plugins SearchWP and Relevanssi?
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:
The following shortcode was used to create the Search Results example.
[ajax_load_more post_type="post,page" posts_per_page="4" search="' . $term . '" orderby="relevance" scroll="true" css_classes="plain-text" button_label="Show More Results"]
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.