Updated with a much faster mysql query to load main content