Cut a 2X4 in the length that you want your shelf or mantel.
Then, cut a 2X4 board 1 1/2 inches shorter than the depth of your shelf that you wanted.
Make sure you don’t put your smaller pieces where the studs are in the wall. I put the back of my frame up on the wall and found the studs, then made marks were they were.
You will screw the shorter pieces onto the long piece. Make sure to use a drill bit and pre-drill the holes, the wood might crack if you don’t.