Just run a normal tax_query
and set the field
parameter to slug
in the query. I assume that you already have a way getting the array of slugs
(Requires PHP5.4+)
$args = [
'post_type' => 'product',
'posts_per_page' => 12,
'tax_query' => [
[
'taxonomy' => 'TAXONOMY_NAME',
'field' => 'slug',
'terms' => ['something', 'something-again', 'something-else'],
]
],
];
$loop = new WP_Query( $args );
EDIT
From comments, these slugs are in actual fact post slugs and not term slugs. In this case, you will need to query posts with get_page_by_path()
. You will need to have an array of slugs and then use a foreach
loop to query the posts
You can try the following: (Just make sure the post type is correct, I have used product
here)
$slugs_array = ['something', 'something-again', 'something-else'];
foreach ( $slugs_array as $v ) {
$post = get_page_by_path( $v, OBJECT, 'product' );
// If we don't have a valid post object, continue
if ( !$post )
continue;
// Setup postdata to make template tags available
setup_postdata( $post );
the_title();
}
wp_reset_postdata();