Refactor posts and pages view