The issue is “elseif ( $page_type == ‘blogpage’ )”
Ignoring the loop, none of the html is showing up. Which mean the $page_type isn’t matching. I can see near the top of the loop you use str_replace on the $page_type. Why do you do this? You’re matching strings, you can have capital letters and spaces, it’s ok. This only serves to screw things up.
What I would test first is in the foreach loop, just echo out each $page_type value so you can see what values it’s pulling from the database. You’ll see why it’s not matching your “blogpage” value. It’s probably grabbing “blogpage1”, or not getting any kind of “blogpage” value at all. Try that and report back with the results.