This question already has an answer here:
In Blender Cycles, can a material be formatted so that, when rendering, it ONLY shows the shadows that were cast upon it by objects? This could be used when using a 360° HDRI as world background, to have an object appear to cast shadows on the background.
As an example, in the picture the plane is added to give the cube a shadow. Unfortunately the entire plane keeps showing up in the rendering. I would like to render the cube and the shadow ONLY, as to generate the impression that the cube is sitting on the road deck. Making the material of the plane (but not the shadow) invisible/transparent would do the job. The question is, how?