term_description()からpタグを消す
<head>内のディスクリプションにタームの説明文を載せたかったのでterm_description()で呼び出そうとしたのですが、デフォルトでは<p>で囲んであるので、それを消したい時に使った方法。
<?php
$term_desc = term_description();
$desc = "「" . $term . "」のタグがついている映画の感想記事一覧です。" . strip_tags($term_desc);
?>
strip_tags() | 文字列から HTML および PHP タグを取り除く |
strip_tags()で囲むことによって<p>を消しています。
参考
- category_descriptionやtag_descriptionのPタグを消す
http://www.02320.net/erase-wpautop-from-term-description/ - term_description() – Function | Developer.WordPress.org
https://developer.wordpress.org/reference/functions/term_description/ - PHP: strip_tags - Manual
https://www.php.net/manual/ja/function.strip-tags.php