php – How to set a featured image as a background for a specific category?

I am currently trying to set the featured image of the most recent publication as the background of my hero image. This is the code I am using:

ID), & # 39; full & # 39;);?>

The problem is that it shows the highlighted image of the most recent throughout the site. I'm trying to make him use the most recent featured image of a specific category (the ID is 42). Could I do something like this?

ID; cat = "45"), & # 39; full & # 39;);?>