Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_get_block_templates

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
625       * @param array  $query {
626       *     Optional. Arguments to retrieve templates.
627       *
628       *     @type array  $slug__in List of slugs to include.
629       *     @type int    $wp_id Post ID of customized template.
630       *     @type string $post_type Post type to get the templates for.
631       * }
632       * @param string $template_type wp_template or wp_template_part.
633       */
634      $templates = apply_filters( 'pre_get_block_templates', null, $query, $template_type );
635      if ( ! is_null( $templates ) ) {
636           return $templates;
637      }
638
639      $post_type     = isset( $query['post_type'] ) ? $query['post_type'] : '';
640      $wp_query_args = array(
641           'post_status'    => array( 'auto-draft', 'draft', 'publish' ),
642           'post_type'      => $template_type,
643           'posts_per_page' => -1,