Working with unqueryable post types in L&L

A Facebook group member was asking about how to work with post types in WordPress that are set to not be publicly queryable (in other words, they have data in the back end and can be queried, but don’t have their own post page). Since Facebook’s code formatting is terrible, I thought I’d share the template here. Hopefully it can benefit anyone looking for this kind of solution in the future!

Whether a post type is public or not is set in the post type settings, meaning that any solution related to this is going to require a post type loop. In the current version (4.0.1), there is no field to easily check whether a post type is public, but it is possible to filter a type loop query to only show public post types (which is the default with public=true so there’s no need to specify it). Here’s how I would go about creating a simple unordered list that shows a “read more” link if the post type is publically queryable and shows the message “(this content is top secret)” when the post type isn’t public. This could obviously be removed to just show read more links on public post types.

<Note>We start by saving a list of public post type</Note>
<List name="public_post_types">
  <Loop type="type">
    <Item><Field name /></Item>

  <Loop post_type="my_secret_post_type,post">
      <Field title />
      <Note>We only display the read more link if our list includes the post type of the current post</Note>
      <If list="public_post_types" includes value="{Field type}">
        <a href="{Field url}">Read more</a>
        <Else />
        (this content is top secret)