How do I account for total effect of a variable in a regression? Suppose I want to understand the influence of gender $X$ on wage $Y$, so I use the linear regression model
$$
Y=\beta X + \varepsilon
$$
We might want to be conscious of omitted variable bias, so we include a control variable $Z$, for example, college major choice. Now we have
$$
Y = \beta X + \gamma Z + \varepsilon
$$
The usual interpretation of $\beta$ in this equation is that it is the effect of gender on wage, given that two individuals chose the same college major. However, what if gender (by way of sexism, cultural expectations, etc.) affects college major choice as well? There a lot of causes for $Z$, some of which are related to gender and some of which are not. How can I create a model that accounts for the total effect of gender on wage, including all these intermediate effects, but also removing non-gender-related causes for $Z$?
 A: This is a really good question! The short answer is that you don't want to add major choice as a control variable and you will get the total effect of gender on wage (edit: if you wanted the direct impact then you would have to worry more about omitted variables).
You are absolutely correct in thinking that when you have a treatment you generally want to control for confounders, which are variables that would impact both the treatment and the outcome variable.
However in this case, the variable major choice—as well as many other variables that gender would impact—is NOT a confounder. This is because Gender is impacting major choice, not the other way around. I think it is most helpful to think about the causal mechanisms in terms of Directed Acyclic Graphs, or DAGs, so that you can understand what it makes sense to control for, when looking for total effects, and what doesn't.
DAGs
Here we have a DAG that looks like this (where studiousness is there as a possible confounder on major choice, but many others are possible):

We are saying that Gender impacts major choice and Wage, major choice also impacts wage, and there are some variables that impact both major choice and wage.
If we don't control for major choice, then we are actually getting the relationship we want! Even though gender impacts major choice and major choice impacts wage, we don't have to control for it because the initial model $Y = X\beta + \epsilon$ captures the impact that gender has on wage without making way for possible confounding effects of studiousness.
We want to include a control variable when it might have an impact on both the treatment and the outcome, for instance if we wanted the impact of major choice on wage, then we would want to control for gender because it would create a connection where there might otherwise not be one.
Think for instance of the example of someone who has cigarettes but never smokes them. If you ran a regression with cancer as the outcome and has cigarettes as the explanatory variable, then you would get a very large significant effect. But if you controlled for "smokes cigarettes" that effect would largely vanish. Smokes cigarettes is a confounder for cancer and "has cigarettes." This is a different causal relationship than the case of gender on wages.
