First up, the first thing you should do is read the developer docs. This question touches on a lot of topics, and it’s not going to be possible to explain them all in one answer.
Anyway, directory
would be a Custom Post Type registered by the theme or a plugin.
When a post type is registered the developer can tell WordPress what the URL path for its archive should be.
WordPress will then create a rewrite rule so that when a user visits that URL, WordPress receives a parameter that tells it that the user is requesting the archive for that post type.
When the user visits that URL WordPress will query the posts it needs to show for that post type archive. It will do that with a WP_Query()
object. As part of this query WordPress will set the is_post_type_archive
property of that object to true
, and the post_type
property to directory
.
Developers can change the behaviour of post queries using the pre_get_posts
filter. Since WordPress can run more than one post query on any given request, any functions used on this filter will receive the current WP_Query
object as a parameter. The developer can then choose to modify the only the main query for the post type archive by checking if $query->is_post_type_archive( 'directory' )
is true
for the current query.