Rename Post Formats options
-
I use Post Formats to style posts. In my case I use ‘Chat’ and ‘Quote’. Where I use the ‘Chat’ format to indicate posts that are featured and the ‘Quote’ format to indicate posts that have a large title size.
In the Classic Editor I had renamed them ‘Featured’ and ‘Typography’. This makes it easier for the editors/writers to know which one to choose for their posts. But I can’t get a script to rename them to work in the Block Editor.
// Enable support for Post Formats. add_theme_support( 'post-formats', [ 'chat', 'quote' ] ); add_post_type_support( 'post', 'post-formats' ); function custom_rename_block_editor_post_formats( $editor_settings ) { // Define custom labels for post formats $custom_formats = [ 'Chat' => __( 'Featured', 'textdomain' ), 'Quote' => __( 'Typografic', 'textdomain' ) ]; // Modify post format labels in the block editor settings if ( isset( $editor_settings['settings']['formats'] ) ) { foreach ( $custom_formats as $format => $label ) { if ( isset( $editor_settings['settings']['formats'][ $format ] ) ) { $editor_settings['settings']['formats'][ $format ]['title'] = $label; } } } return $editor_settings; } add_filter( 'block_editor_settings_all', 'custom_rename_block_editor_post_formats' );
This code does nothing. At the suggestions of others I also tried with gettext instead of textdomain. Which also did not work. I’m testing the code on a fresh WordPress 6.5.2 install with Twenty Twenty-Four (twentytwentyfour) theme.
It seems I may be using the wrong filter? How do I get this code to work?
- The topic ‘Rename Post Formats options’ is closed to new replies.