- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/strip shortcodes
提供: WordPress Codex 日本語版
目次
説明
渡されたコンテンツから ショートコード タグをすべて削除します。
使い方
<?php strip_shortcodes( $content ); ?>
パラメータ
- $content
- (文字列) (必須) ショートコードタグを削除するコンテンツ。
- 初期値: なし
戻り値
- (文字列)
- ショートコードタグを含まないコンテンツ。
用例
ホームページからショートコードを取り除くけれども単一投稿やアーカイブページは対象外
投稿を「ホーム」ページで見るときはショートコードをすべて取り除くけれども、single.php などの他のページでは取り除かないという例です。
function remove_shortcode_from_index( $content ) { if ( is_home() ) { $content = strip_shortcodes( $content ); } return $content; } add_filter( 'the_content', 'remove_shortcode_from_index' );
参考
変更履歴
新規導入: 2.5
ソースファイル
strip_shortcodes() は wp-includes/shortcodes.php
にあります。
関連項目
ショートコード:
do_shortcode(),
add_shortcode(),
remove_shortcode(),
remove_all_shortcodes(),
shortcode_atts(),
strip_shortcodes(),
shortcode_exists(),
has_shortcode(),
get_shortcode_regex(),
wp_audio_shortcode(),
wp_video_shortcode(),
フィルター no_texturize_shortcodes /en
関数リファレンス、テンプレートタグ目次もご覧ください。
最新英語版: WordPress Codex » Function Reference/strip_shortcodes (最新版との差分)