Accessing $post global on a custom post type archive page
I have a custom post type called projects, and its archive is at /projects
, on the archive page I get notices Notice: Trying to get property of non-object
every time I try to access the $post
i.e. $post-post_name
. Is this intended behaviour? Should I just accept that and always check the availability of $post
before using it?
if (!empty($post)) {
// Do something with $post
}