钩子文档

template

💡 云策文档标注

概述

本文档介绍 WordPress 中的 'template' 过滤器,用于过滤活动主题的名称。它允许开发者修改或获取当前主题的目录名。

关键要点

  • 'template' 过滤器用于过滤活动主题的名称,参数为当前主题的目录名。
  • 该过滤器通过 apply_filters 调用,源代码如下:apply_filters( 'template', get_option( 'template' ) )。
  • 相关函数包括 get_template(),用于检索活动主题的名称。
  • 此过滤器自 WordPress 1.5.0 版本引入。

📄 原文内容

Filters the name of the active theme.

Parameters

$templatestring
active theme’s directory name.

Source

return apply_filters( 'template', get_option( 'template' ) );

Changelog

Version Description
1.5.0 Introduced.