钩子文档

the_preview

💡 云策文档标注

概述

the_preview 是一个 WordPress 过滤器,用于在预览模式下过滤单个文章。它允许开发者在文章预览时修改文章对象。

关键要点

  • 过滤器名称:the_preview
  • 主要用途:在预览模式下过滤文章对象
  • 参数:$post_preview(WP_Post 对象)和 $query(WP_Query 实例,通过引用传递)
  • 引入版本:WordPress 2.7.0
  • 相关函数:在 WP_Query::get_posts() 中使用,用于基于查询变量检索文章数组

代码示例

$this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );

📄 原文内容

Filters the single post for preview mode.

Parameters

$post_previewWP_Post
The Post object.
$queryWP_Query
The WP_Query instance (passed by reference).

Source

$this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );

Changelog

Version Description
2.7.0 Introduced.