<?php
if(have_posts()){
while(have_posts()){
the_post();
echo get_the_title();
}
}
?>
this is my loop, really simple, im calling this within a custom page template i made called services, i expect the posts titles to pop up, but instead im just getting services.
get_the_post()
it's going to give the page title.get_post()
etc work on the global post object when no post is specified in the first parameter. When you're callinghave_posts()
,the_post()
, etc, you're actually asking WordPress to use this global post. In the context of WordPress, Pages, Posts, and Custom Post Types are all "posts", just of different types. So,have_posts()
istrue
because the page you're on is a post, just a post with thepost_type
ofpage
.