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
1035       *     Arguments to retrieve templates. All arguments are optional.
1036       *
1037       *     @type string[] $slug__in  List of slugs to include.
1038       *     @type int      $wp_id     Post ID of customized template.
1039       *     @type string   $area      A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).
1040       *     @type string   $post_type Post type to get the templates for.
1041       * }
1042       * @param string $template_type Template type. Either 'wp_template' or 'wp_template_part'.
1043       */
1044      $templates = apply_filters( 'pre_get_block_templates', null, $query, $template_type );
1045      if ( ! is_null( $templates ) ) {
1046           return $templates;
1047      }
1048
1049      $post_type     = isset( $query['post_type'] ) ? $query['post_type'] : '';
1050      $wp_query_args = array(
1051           'post_status'         => array( 'auto-draft', 'draft', 'publish' ),
1052           'post_type'           => $template_type,
1053           'posts_per_page'      => -1,