aioseo_local_business_get_locations_by_category_posts

Purpose

This filter can be used to change the locations by category queried.

Arguments (1)

  1. $posts (array) – An array of WP_Post.
  2. $args (array) – WP_Query accepted arguments.
  3. $termId (int) – The queried term ID.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below we remove a specific location from the results.

add_filter( 'aioseo_local_business_get_locations_by_category_posts', 'aioseo_change_local_business_get_locations_by_category_posts', 10, 3 );

function aioseo_change_local_business_get_locations_by_category_posts( $posts, $args, $termId ) {
	if ( 14 === $termId ) {
		foreach ( $posts as $key => $post ) {
			if ( 232 === $post->ID ) {
				unset( $posts[ $key ] );
			}
		}
	}

	return $posts;
}