Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_get_block_template

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
754       * Return a non-null value to bypass the WordPress queries.
755       *
756       * @since 5.9.0
757       *
758       * @param WP_Block_Template|null $block_template Return block template object to short-circuit the default query,
759       *                                               or null to allow WP to run its normal queries.
760       * @param string $id                             Template unique identifier (example: theme_slug//template_slug).
761       * @param string $template_type                  Template type: `'wp_template'` or '`wp_template_part'`.
762       */
763      $block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );
764      if ( ! is_null( $block_template ) ) {
765           return $block_template;
766      }
767
768      $parts = explode( '//', $id, 2 );
769      if ( count( $parts ) < 2 ) {
770           return null;
771      }
772      list( $theme, $slug ) = $parts;