WordPress Pods: Properly formatted output from ‘desc’ fields

A few months ago, I discovered the Pods plugin for WordPress, and it’s completely changed the way I go about building many projects. It essentially adds CMS functionality to WordPress, allowing you to create your own input modules and display them however you want. The Pods website homepage has a video that explains the plugin much better than I do.

It’s a new project though, and there’s not a whole lot of documentation for it at the moment, so it’s handy when users find solutions to common problems and share them.

In that vein, I’ve been having a problem in that the default WYSIWYG editor for textfields in Pods outputs text with multiple line breaks between paragraphs, rather than just creating new paragraphs as I want.

By adding this Display Helper to a field, the helper searches the field content for any reference of ‘<br>’ or ‘<br />’ and replaces it with ‘\n’ (just a new line, as if someone had pressed Return). Then the wpautop function from WordPress looks for any block of text surrounded by double-new-lines and adds the correct block-level tag around it, such as ‘<p>’.

Here is the Display Helper code:

<?php
$value = str_replace(array('<br />', '<br>'), "\n", $value);
echo wpautop($value); ?>

Comments on WordPress Pods: Properly formatted output from ‘desc’ fields

Scott Kingsley Clark

Great job with this! Did you post this as a Package yet?

Posted by Scott Kingsley Clark (1 comments) on 24th September, 2009 at 12:20 am.

Rob Barrett

Thanks, Scott. I’ve just added it as a Package now. That should be a great feature once the library builds up!

Posted by Rob Barrett (45 comments) on 24th September, 2009 at 9:36 am.

ohare airport limo service

It seems to be a great plugin. Can I asked what tool or plugin do you use to present the keywords I search to come up with this page?

Posted by ohare airport limo service (7 comments) on 23rd April, 2010 at 9:10 am.

Bill Bennett

Rob – what are you using Pods for?

I think they are the answer to a problem I have but I’m interested in seeing some practical applications from other people.

Posted by Bill Bennett (1 comments) on 30th May, 2010 at 6:42 am.

Web design Darwin

Very handy codes. It is simple but it can help a lot. I’m really loving your blog because I’m learning a lot about web designing. Keep it up because you are helping a lot of people.

Posted by Web design Darwin (2 comments) on 11th June, 2010 at 6:15 am.

Leave a Comment





Rob Barrett Introduction