WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Line breaks in Custom Fields (6 posts)

  1. stew278
    Member
    Posted 8 years ago #

    I'm having troubles with content in custom fields not having a line break where I've inserted a hard return. I would like to avoid having to administer posts from other authors, just to enter BR tags in their posts (inside the custom fields).

    Is there something out there that successfully addresses this problem of not being able to have line breaks in custom fields?

  2. carthik
    Member
    Posted 8 years ago #

    http://wordpress.org/support/topic/29623

    and some other forum/weblog posts have the answers.

    Try searching using yahoo for "line breaks in custom fields wordpress" or similar.

  3. Kafkaesqui

    Posted 8 years ago #

    Hmm.

    Actually, managing this wouldn't be hard. You'd only need to pass whatever is displaying the custom field value through WordPress' wpautop() function. For example, I might use the following to display only custom field values with the key 'test':

    <?php if(get_post_custom_values('test')) {
    foreach(get_post_custom_values('test') as $value) {
    echo wpautop($value);
    }
    } ?>

    Whatever code/plugin used could be easily modified.

  4. stew278
    Member
    Posted 8 years ago #

    Sorry, but I have to ask this (as I'm not that well versed in php and new to WordPress), but how would that look with the C2C plugin:

    <?php echo c2c_get_custom('Ingredients'); ?>

    I've seen before something about "wpautop" but have had no luck in successfully implementing it.

  5. Kafkaesqui

    Posted 8 years ago #

    This would do it:

    <?php echo wpautop(c2c_get_custom('Ingredients')); ?>

  6. stew278
    Member
    Posted 8 years ago #

    Great! Thanks for that bit ... works great for me :)

Topic Closed

This topic has been closed to new replies.

About this Topic