The following general reaction proceeds with decrease in amount of substance, so increasing pressure should shift the position of equilibrium to the right.
$$\ce{2 A(g) <=> B(g)}$$
But let's say the forward reaction is endothermic, and both $\ce{A}$ and $\ce{B}$ are gases. This means if the position shifts to the right, there will be an increase in temperature and consequently an increase in gas pressure. Then why will the equilibrium shift towards right side upon increasing the pressure?
Does the effect of pressure on the position of equilibrium depend on whether we have an endothermic or exothermic reaction?