Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
Purpose
This filter can be used to change the locations posts.
Arguments (1)
- $posts (array) – An array of WP_Post.
- $args (array) – WP_Query arguments.
Example code snippet
The code snippet below is just an example of how this filter can be used. In the example below we exclude locations in the location-category ‘florida’.
add_filter( 'aioseo_local_business_get_locations_posts', 'aioseo_change_local_business_get_locations_posts', 10, 2 );
function aioseo_change_local_business_get_locations_posts( $posts, $args ) {
foreach ( $posts as $key => $post ) {
if ( in_array( 'florida', wp_get_object_terms( $post->ID, aioseo()->addons->localBusiness->taxonomy->getName(), [ 'fields' => 'slugs' ] ) ) ) {
unset( $posts[ $key ] );
}
}
return $posts;
}