カスタムフィールドに入力した値の改行 Comment

5:56 PM on 2011年11月25日

WordPressでカスタムフィールドを頻繁に使いますが、この入力欄に入力したテキストについて改行を反映させたい場合、2種類の記述方法があります。

自動的にPタグでマークアップする

1
<?php echo wpautop(post_custom('カスタムフィールドの値')); ?>

自動的にBRタグを挿入するだけでPタグなどの自動整形はしない。

1
<?php echo nl2br(get_post_meta($post->ID,'カスタムフィールドの値',true)); ?>

Leave a Reply

Have something to say? Jump right in!     Formatting

(required)
(required)

Close

Formatting Your Comment

The following XHTML tags are available for use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

URLs that start with http:// are automatically converted to hyperlinks.