Yes, you can substitute all-purpose flour with whole wheat flour in a cake recipe, but there are a few things to consider:
Texture and Density: Whole wheat flour has more protein and fiber than all-purpose flour, which can result in a denser and slightly coarser texture in the cake. It may not be as light and fluffy as when using all-purpose flour.
Hydration: Whole wheat flour absorbs more moisture than all-purpose flour. When substituting, you may need to increase the liquid content in the recipe slightly to compensate for this. Otherwise, your cake could turn out dry.
Flavor: Whole wheat flour has a nuttier and heartier flavor compared to the more neutral taste of all-purpose flour. This flavor difference might be noticeable in the final cake.
Rising Agent: If the recipe calls for baking powder or baking soda as a leavening agent, the extra protein in whole wheat flour can interfere with the rising process. To help with this, you could add a bit of extra baking powder/soda or use a combination of both all-purpose and whole wheat flour.
Quantity: The substitution ratio is not always one-to-one. Whole wheat flour is denser, so you may need to use slightly less whole wheat flour than the amount of all-purpose flour called for in the recipe. A common substitution ratio is 3/4 cup of whole wheat flour for every 1 cup of all-purpose flour.
Recipe Adaptation: Some cake recipes might not work well with whole wheat flour due to its distinctive properties. Cakes that are already rich in flavors, such as carrot cake or spice cake, tend to handle the substitution better than delicate cakes like sponge cakes.
If you decide to proceed with the substitution, it's a good idea to do a small test batch first. This way, you can adjust the recipe as needed before making the full cake. Keep in mind that while the cake may have a different texture and flavor, it can still be a tasty and healthier alternative with the whole wheat flour.