The Terms extension provides additional functionality for infinite scrolling taxonomy terms with Ajax Load More.

The extension uses a WP_Term_Query to retrieve taxonomy terms and returns them to Ajax Load More for display.


Repeater Template

Term information must be accessed Repeater Templates by referencing the $term object.

<div>
	<h3>
		<a href="<?php echo get_term_link( $term->term_id ); ?>">
			<?php echo $term->name; ?>
		</a>
	</h3>
	<p><?php echo $term->description; ?></p>
</div>
PHP

Shortcode Parameters

Use the following shortcode parameters to initiate a term query with Ajax Load More.

term_queryEnable Terms Query. (true/false) Default = ‘false’
term_query_taxonomyThe taxonomy slugs to query.
term_query_numberThe number of terms to return per page. Default = 5
term_query_hide_emptyWhether to hide terms not assigned to any posts. Default = true
Example Shortcode[ajax_load_more term_query="true" term_query_taxonomy="category" term_query_number="8"]

Note: You can modify or add additional query parameters by using the alm_term_query_args filter.


Example

The example below will lazy load load terms from the category taxonomy and get all associated posts by the term. Click the Load Terms button to get started.


Filter Hooks

The following Ajax Load More filters support modifying term query arguments.

alm_term_query_args_{id}

The alm_term_query_args_{id} filter can modify or extend  WP_Term_Query arguments by Ajax Load More instance ID.

function my_category_listing( $args ){
	// [ajax_load_more id="category_listing" term_query="true" term_taxonomy="category"]
	// 'term_listing' is the value of the 'id' parameter in the shortcode.

	$args['hide_empty'] = false;
	$args['order'] = "ASC";  
	return $args; 
}
add_filter( "alm_term_query_args_category_listing", "my_category_listing", 10, 2 );
PHP

This filter requires the following 2-step process:

  1. Set Unique ID: Create a unique ID for the ALM instance by setting a value for the id parameter.
    [ajax_load_more id="category_listing" term_query="true" term_taxonomy="category"]
  2. Add Filter: Create the custom hook for this instance by appending the unique ID to the filter name.
    add_filter( ‘alm_term_query_args_category_listing’, ‘my_function_name’ );

When is this filter useful?

This filter is useful for users who need to extend the available term query shortcode parameters.

Check out the WP_Term_Query docs for details on the available query arguments.