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 plugins SearchWP and Relevanssi?
Your search for 'WordPress returned the following results:
The following code should be placed inside your page template where you want Ajax Load More to display.
1 2 3 4 5 6 7 |
<?php $term = sanitize_text_field($_GET['term']); if(empty($term)){ $term = 'WordPress'; } echo do_shortcode('[ajax_load_more post_type="post, page, portfolio" search="'. $term .'" orderby="relevance" posts_per_page="4" scroll="true" css_classes="plain-text" button_label="Show More Results"]'); ?> |
Note: When using Ajax Load More on search.php templates, $_GET[‘term’] should be $_GET[‘s’].
The following shortcode was used to create the Search Results example.
[ajax_load_more post_type="post, portfolio" 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 and therefore it must be added to a page using the do_shortcode method.