post_excerpt_meta_box()
概述
post_excerpt_meta_box() 函数用于在 WordPress 后台编辑器中显示文章摘要表单字段,包括一个文本区域和帮助链接。
关键要点
- 函数接受一个必需的参数 $post,类型为 WP_Post 对象,代表当前文章
- 输出包含一个文本区域用于输入摘要,并链接到 WordPress 官方文档以了解更多信息
- 该函数自 WordPress 2.6.0 版本引入,属于核心功能
代码示例
function post_excerpt_meta_box( $post ) {
?>
<label for="excerpt"><?php _e( 'Excerpt' ); ?></label>
<textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p><?php
printf(
__( 'Learn more about manual excerpts.' ),
__( 'https://wordpress.org/documentation/article/what-is-an-excerpt-classic-editor/' )
);
?></p>
<?php
} Displays post excerpt form fields.
Parameters
$postWP_Postrequired-
Current post object.
Source
function post_excerpt_meta_box( $post ) {
?>
<label class="screen-reader-text" for="excerpt">
</label><textarea rows="1" cols="40" name="excerpt" id="excerpt">post_excerpt; // textarea_escaped ?></textarea>
<p>
Learn more about manual excerpts</a>.' ),
__( 'https://wordpress.org/documentation/article/what-is-an-excerpt-classic-editor/' )
);
?>
</p>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-admin/includes/meta-boxes.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/meta-boxes.php#L745">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/meta-boxes.php#L745-L763">View on GitHub</a></p></section>
<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/_e/">_e()</a><code>wp-includes/l10n.php
Displays translated text.
__()wp-includes/l10n.php
Retrieves the translation of $text.
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |