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

Startup Hero

The Official Blog Of Name Hero

Learn To Fly Above The Competition Get Started
  • HomeWelcome
  • CoursesVideo Training Center
  • About UsWhat is StartupHero?
  • BlogGet the latest
  • Start HereStartup 101
  • SpeakingPodcast & Media
  • ResourcesTools to help You
    • Reselling WordPress Hosting
    • Resell Hero
    • How To Start A Blog
  • NameHeroCloud Web Hosting

Two Filters That No Longer Work In Gutenberg (And Workarounds)

By Bhagwad Park on January 19, 2023 0

Two Filters That No Longer Work In Gutenberg (And Workarounds)

While updating some of my older WordPress posts, I noticed that some of the code I’d used that worked with the older classic editor no longer works with Gutenberg. Even though I admitted my mistake and embraced Gutenberg, it’s annoying that the two filters I used no longer work. In this article, I’ll document three use cases.

1. “post_updated_messages” Filter

The first filter that I miss in Gutenberg is called “post_updated_messages”. In the classic editor, the WordPress system triggered this filter whenever a post was updated, and we could use it to change the message that appeared on the top of the editor. I found this filter most useful whenever I wanted to check the post’s content and, if necessary, revert the status based on some criteria.

For the first example, let’s say you want to include a minimum or maximum title length for your post writers. To ensure that they comply, I would use the “post_updated_messages” to check the length of the title, and if it was too long, I would unpublish the post with an error message on top.

As a second example, if you have a lot of guest writers, you want to ensure that they don’t link out too often. If you’re paranoid, you might worry that they’re accepting payment for linking to a 3rd party website. You could use the “post_updates_messages” notification to check the content for links to 3rd party domains, and then unpublish the post and mark it as pending when you can review it later.

With Gutenberg, actions like this are no longer possible.

2. “post_link” Filter No Longer Fires on the “Insert Link” Tool

We can use the “post_link” filter to change the URL returned by WordPress for a given post object. I used this filter to allow the “Insert Link” tool to return the “pretty permalinks” of even draft posts. This allowed me to create pages in advance, interlink them all, and then publish them all at once. Previously, linking to a draft post would only insert the “ugly” permalink used for previews.

Unfortunately, the “post_link” filter no longer fires when you insert a link using the Gutenberg editor in WordPress. I can’t link to draft posts with pretty permalinks anymore. It’s not too big of a loss in functionality, but for those who needed it, the loss hurts.

Filtering “admin_notices” Instead of “post_updated_messages”

As a poor workaround, the “admin_notices” filter can be used for some cases where you previously had the “post_updated_messages” filter. It’s far from perfect and doesn’t work at all while editing a post, so it’s useless to verify the content of a post. But at least you can still use it when you inform the user that they need to update a plugin or theme.

Keep Using the Classic Editor if you Need To

In the worst-case scenario, you can always install the WordPress classic editor plugin. Even though the WordPress team says they’ll maintain it only till 2024, there’s a good chance it’ll keep working for longer, as the community will keep updating it for compatibility. For how long? No idea. But in the near future, you can rely on it.

Despite the Loss, Gutenberg is a Huge Step Forward

Annoying as the loss of functionality is, I prefer Gutenberg to the classic editor. My pages are now more than just plain text and contain visual elements I could only dream of before. So I’m not complaining too hard!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Connect With Us!

Superhero Resources

Fix Common Issues

  • How To Setup Free And Automatic SSL Certificates
  • How To Setup Cloudflare With Railgun
  • How To Fix Memory Exhausted Errors In WordPress
  • How To Edit PHP Version/Upload Limit/Add Extensions
  • How To Move/Migrate Your Business To Name Hero

Free Guides

  • How To Setup NameHero Hosting
  • How To Create A Web Hosting Business With WordPress
  • How To Start A WordPress Blog
  • How To Migrate WordPress To A VPS
  • How To Speed Test And Optimize Your WordPress Website
  • Magento 2.X Installation Guide
  • How To Clean Up A WordPress Hack

Training

Recent Posts

  • The Best WordPress Plugin To Combat Plagiarism
  • Is It Time to Bring Back Blog Comments?
  • Two Filters That No Longer Work In Gutenberg (And Workarounds)
  • Migrating To The New Cloudflare Managed Rules Interface
  • How To Sort Posts By The “Last Modified” Date
  • How To Make WordPress Send E-mail From Another Address
Subscribe in a reader
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • VPS Hosting
  • Twitter
  • Facebook
  • LinkedIn
  • YouTube
  • FTC Disclosure
  • Earnings Disclosure
  • Privacy Policy

Copyright © 2023 · Smart Passive Income Pro on Genesis Framework · WordPress · Log in