Site icon Hip-Hop Website Design and Development

How to get a page’s featured image from a term slug (same name)

I have this code (that i’ve inserted into archive.php) that displays a page’s content on the corresponding post category archive with the same slug.

<?php $term = get_queried_object(); ?> <?php $page = get_posts([ 'name' => $term->slug, 'post_type' => 'page']); if ( $page ){ echo $page[0]->post_content; } ?>

I’d like to find a way I can use the term slug to display the page’s featured image.