Work arounds for conditional checks inside the loop in search.php?

Ok, so I still can’t figure out the best way to check if the returned post is the static front page (without getting and comparing the url). However, I figured out how to check if a returned item is using a specific page template using get_page_template_slug(). I didn’t know that function existed before running into this issue. Luckily my front page is using a custom page template, so don’t currently need a work around for is_front_page().

So where I would usually use is_page_template(‘templates/template-name.php’) I was able to check using the following:

$id = get_the_ID();
$template_slug = get_page_template_slug( $id );

if( $template_slug === 'templates/template-name.php' ) :
    do stuff
endif;