I should have my old posts up soon-ish. I figured out how to make WordPress compatible with hard wrapped Markdown.
In the olden days you’d use wpautop-control, but that particular plugin stopped working a while ago.
In the new days… you’d use Advanced Custom Fields. It’s overkill for this, but it’s likely enough to come up that you might as well 😛
First try: on-off switch
It took about two hours total once I thought to try this. The first hour was an on-off switch, implemented as a True/False field:
I exported this to PHP, wired a small filter to it, tried it on a short poem:
To add paragraphs
or not to add paragraphs,
that is the question.
checked it in when it looked like it worked, and deployed it.
Second try: button group
After I deployed it, I tried it on a longer text and noticed all of my paragraph breaks had gone missing. This felt all too familiar.
I remembered that I actually wanted a tri-state switch, since hard-wrapped Markdown wants automatic paragraph insertion but not automatic line break insertion. I made a button group field… and nothing happened. It didn’t appear on my site.
After twenty minutes of Googling, I remembered that ACF’s PHP export adds field groups rather than individual fields. I commented out the field group in my core functionality plugin and the field immediately appeared:
A few minutes later I wired the tri-state together, tested it on a longer poem:
To add breaks
or not to add breaks,
that is the question.To add paragraphs
or not to add paragraphs,
that is the question.
and my problem was solved.