• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Will Angley

Just another WordPress site

  • About
  • Photos
  • Words
  • Resume
  • Contact

Marking myself out of a corner

September 27, 2021 by Will Angley

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.

Filed Under: Words Tagged With: wordpress

About the Author

Will Angley likes to take photos, and pays the bills by writing code for a big company.

Never miss a post!

By clicking submit, you agree to share your email address with the site owner and Mailchimp to receive marketing, updates, and other emails from the site owner. Use the unsubscribe link in those emails to opt out at any time :).

Primary Sidebar

Follow me

  • GitHub
  • Instagram
  • LinkedIn
  • RSS
  • Twitter

Top Posts

  • How I set up Tailscale on my WiFi router
  • Why does installing Wi-Fi still involve knocking holes in walls?

Recent Posts

  • 🗽Statue of Liberty
  • Sunsets are back!
  • Marking myself out of a corner
  • Incident of the day: Bonobos
  • Why does installing Wi-Fi still involve knocking holes in walls?

Categories

  • Photos
  • Words

Copyright © 2014–2023 Will Angley · Privacy Policy · Made with ❤️ and WordPress in NYC