[WP]Advanced Custom FieldsのWYSIWYGフィールドからPタグを除去する方法
スポンサード
Advanced Custom FieldsのWYSIWYG フィールドのテキストを、<P>タグを除去して出力する場合はこのようになります。
スポンサード
WordPressのカスタムフィールド拡張プラグイン「Advanced Custom Fields」で、WYSIWYG Editorに入力した文字列(文章)を出力する際に、<P>タグを除去する方法のご紹介です。
ACF のWYSIWYG Editor のテキストをPタグ除去して出力
通常の投稿や固定ページの本文を、<P>タグを除去して表示する場合は以下のようになりますが、<?php remove_filter ('the_content', 'wpautop'); the_content(); ?>
Advanced Custom FieldsのWYSIWYG フィールドのテキストを、<P>タグを除去して出力する場合はこのようになります。
<?php remove_filter ('acf_the_content', 'wpautop'); the_field("カスタムフィールド名", $post_id); ?>
スポンサード
コメント