Wordpress

How to Hide The WordPress Editor (without plugins)

Have you ever wanted to get rid of that content editor block in your custom post types? You know, that big empty space sitting there taking up room when you don’t need it? This is how you can hide it without using plugins. The Solution All you need is ONE line of code. Just add this to your theme’s functions.php file: remove\_post\_type\_support('your-post-type', 'editor'); Swap out ‘your-post-type’ with whatever post type you’re working with. For example, if you’ve got a custom post type for reviews, you’d use:

Matt Mullenweg is destroying WordPress. Is it time for a fork?

The WordPress community is in turmoil, and at the center of the storm stands Matt Mullenweg, once hailed as a visionary but now increasingly viewed as an open-source dictator. His recent actions have exposed the alarming centralisation of power within WordPress and raised serious questions about the project’s future. Mullenweg’s conflict with WP Engine has laid bare the ugly truth: despite its open-source ethos, WordPress is effectively controlled by one man. His decision to temporarily ban WP Engine from accessing WordPress.org resources not only disrupted countless websites but also demonstrated how easily he can weaponise his position against perceived threats.

Implementing a Logout Feature in WordPress Menus

WordPress, a flexible content management system, allows various customisations to enhance user experience and streamline site management. One common requirement is to provide users with an easy and intuitive way to log out. This guide explores a best practice approach to adding a logout link directly within a WordPress menu, utilizing hooks and filters for a clean and efficient implementation. Opting for a menu item logout link over a separate logout page or relying on plugins offers several advantages:

Adding Custom Cron Schedules in WordPress

WordPress, by its very design, is a platform that offers a high degree of flexibility and customisation. One area that developers often need to customise is the scheduling of tasks within WordPress. The built-in cron system, WP-Cron, simulates a system cron by scheduling tasks at specific intervals. However, the default intervals may not always fit your needs. In this article, we’ll explore how to add custom cron schedules in WordPress, including additional times, such as every 15 minutes.

How to Insert Gutenberg Blocks Using wp_insert_post

It’s 2023, and we still have no simple way to insert Gutenberg blocks into WordPress using wp_insert_post. You’re out of luck if you want to pull content from an API and insert it dynamically with ease. There are methods like parse_blocks and render_blocks but they still require a lot of messing around to work with. The way Gutenberg blocks work is strange. They’re not stored as an array or structured data in the database. They are stored in the HTML as HTML comments.

Programmatically Update the Status of a Post Using Gutenberg JS

In a WordPress project I am building, I needed a way to programmatically update the post status of a post on the edit screen, specifically in the Gutenberg editor. Before arriving at the solution below, I first struggled to figure this out. I was trying to call the updatePost method with a post object and modified status, then calling savePost but what kept happening was the post would revert to draft status.

How to Hide Meta Boxes in WordPress Gutenberg

When WordPress introduced the Gutenberg editor, it was a mess, to say the least. Everything was turned upside for developers and things that worked in previous versions were completely broken when Gutenberg was released. One of the things that were broken in WordPress was the ability to hide a meta box on the editor screen. Instead of setting meta_box_cb to false and expecting the box the hidden, nothing happens. Well, there is a way you can hide meta boxes by using the following snippet of code inside of functions.php

How to programmatically populate a TinyMCE Advanced Custom Fields field in WordPress

The Advanced Custom Fields plugin for WordPress is invaluable. It has filled a gap in WordPress for the better part of a decade and is one of the first plugins that I install in a new WordPress installation (I have a lifetime developer licence). The ACF plugin provides a Javascript API available using acf it has numerous methods for interacting with ACF fields in your WordPress installation. You can programmatically get and set field values, observe for changes and react accordingly.

Programmatically Clicking the “Convert to Blocks” Button in WordPress Gutenberg on the Edit Screen

In the beginning, I was one of the loud developers protesting WordPress Gutenberg. But, now that Gutenberg has been around for a while, I’ve grown to like it. I can’t tell if it’s because of Stockholm syndrome or if it has actually improved. Anyway. One of the looming problems users of WordPress will still face is the fact if you programmatically insert content into WordPress using wp_insert_post or however else you insert content (say from a CSV or API) you’ll find that WordPress will put it into a Classic Editor block. You will then be prompted to “Convert to blocks” in the editor.

How to debug the output from within WordPress filters

WordPress has a great actions and filters system allowing you to create injection points for modifying parts of your code (especially for plugin authors). However, you probably arrived here because you’re trying to echo or print_r something from within a filter and not seeing the output. Because WordPress operates on a post/redirect approach, it means you’re not seeing the output because the page has been reloaded. You need to kill the script from within your filter callback function to see the output.