Checking condition if on a custom post type singular or custom post type archive

Home / WordPress / Checking condition if on a custom post type singular or custom post type archive

If you want to check if you are on custom post type singular or custom post type archive within your WordPress website, you can perform the following check:

In this particular case, we are checking if we are on locations custom post type or on the archive of that CPT.