Skip to main content
72 votes
Accepted

Enable Gutenberg on custom post type

For Gutenberg to work in a Custom Post Type you need to enable both the editor in supports (which you already have) and show_in_rest. So add 'show_in_rest' => true, to your post registration ...
Alvaro's user avatar
  • 2,583
26 votes

how to know if admin is in edit page or post

Better way: global variable $pagenow global $pagenow; if (( $pagenow == 'post.php' ) || (get_post_type() == 'post')) { // editing a page } if ($pagenow == 'profile.php') { // editing ...
T.Todua's user avatar
  • 5,810
16 votes
Accepted

Gutenberg editor add a custom category as wrapper for custom blocks

Digging myself deeper in documentation, I got the following result. There is a way to group your custom blocks around a given category in Gutenberg, and therefore we have the method ...
fefe's user avatar
  • 874
10 votes

Enable Gutenberg on custom post type

Start by registering a Gutenberg WordPress custom type. The process is fairly easy and involves adding the following the code snippet. /*Register WordPress Gutenberg CPT */ function cw_post_type() { ...
Owais Alam's user avatar
9 votes

Forcing reload of editor-style.css

I couldn't get toscho's answer to work for the current version of WordPress (4.7.2), and that seems to be because the TinyMCE init array has a cache_suffix set to 'wp-mce-' . $tinymce_version. So ...
icecold_3000's user avatar
8 votes

how to know if admin is in edit page or post

Use 'get_current_screen', just make sure beforehand, it exists. As codex says "This function is defined on most admin pages, but not all." This btw also filters out normal (reader-facing) views (re-...
Frank N's user avatar
  • 465
8 votes
Accepted

How to create WP Editor using javascript

Thanks to Jacob Peattie's comment I can answer this using JS only. Actually we did something similar, but prior 4.8 and it wasn't this easy, so we did use wp_editor() in the end. But now, you can do ...
kero's user avatar
  • 6,220
8 votes
Accepted

Disable text tab on WordPress text-editor

For disabling the text tab for all users except administrators, you can add the following: function my_editor_settings($settings) { if ( ! current_user_can('administrator') ) { $settings['...
L.Milo's user avatar
  • 193
7 votes
Accepted

How to display warning on post editor when trying to add new term to custom taxonomy?

Whilst this doesn't show a warning as you are asking for, you could always hide the "add new" link using the admin_head action: function yourprefix_admin_head() { echo '<style> #language-...
Alexander Holsgrove's user avatar
7 votes

How to create WP Editor using javascript

WP 5.3.2 Currently building a plugin with Ajax page loading, needed to get data from multiple WP editors that are dynamicly loaded. NOTE: Below example is for the wp-admin area, if you want this ...
Bjorn's user avatar
  • 535
6 votes

Wordpress crop tool greyed out

For me, the button became available once I clicked and dragged the mouse cursor over part of the image to select an area to crop.
Highly Irregular's user avatar
6 votes

Admin: very slow edit page caused by core meta query

If you browse through the source code of the function you'll find this: $keys = apply_filters( 'postmeta_form_keys', null, $post ); if ( null === $keys ) { ... } Using the ...
Dan K's user avatar
  • 61
6 votes
Accepted

WordPress 4.6 link edit dialog is too rudimentary

To disable the inline link tool and revert it back to a pop-up screen instead, do the following: In your child theme directory, add the following to your function.php: add_filter( '...
Ethan O'Sullivan's user avatar
5 votes

Wordpress crop tool greyed out

The crop tool and edit-image interface is not as intuitive as it could be. For anyone looking for why the crop tool is deactivated and the save button is greyed-out, here are the steps for getting ...
Mike Kormendy's user avatar
5 votes
Accepted

Missing .twig files in wordpress theme editor

The thing you need to do is update the filter with the "allowed" editor file types. Here's what you'll need for TWIG: function add_custom_editor_file_types( $types ) { $types[] = 'twig'; ...
Paul G.'s user avatar
  • 1,244
4 votes

How to include own css on wordpress tinymce editor?

Nothing I found worked. Took me half a day on Google, but finally stumbled upon this script that works: function kwh_add_editor_style( $mceInit ) { $custom_css = get_theme_mod( 'custom_css' ); $...
AA-T's user avatar
  • 51
4 votes
Accepted

How to enable the theme editor cap for an editor role?

The edit_themes capability is what allows access to Appearance > Theme Editor: function wpse243341_modify_editor_role() { $role = get_role( 'editor' ); $role->add_cap( 'edit_themes' ); } ...
Dave Romsey's user avatar
  • 17.7k
4 votes

wp.media edit attachment screen

Long answer: Peeking into wp-includes/js/media-models.js, I see this: if ( 'select' === attributes.frame && MediaFrame.Select ) { frame = new MediaFrame.Select( attributes ); } else if ( '...
user63350's user avatar
  • 171
4 votes

Why wordpress word count differs from Microsoft word and sites like wordcounter.net

WordPress removes HTML entities, convert connectors (-- or em-dash) to spaces, removes unwated characters (General Punctuation, Superscripts and Subscripts, Currency Symbols, Combining Diacritical ...
KAGG Design's user avatar
  • 1,842
4 votes
Accepted

Add option for editors through `register_setting`

To allow users with capabilities other than manage_options to save a setting you can use the option_page_capability_{$option_page} hook. Despite the name, {$option_page} is the option group, which is ...
Jacob Peattie's user avatar
4 votes

Gutenberg block editor - list of form components for custom blocks

There are two main packages that provide components which can be used inside the blocks API or the plugins API (to create your own blocks or plugins). The components found in the wp.components ...
Alvaro's user avatar
  • 2,583
4 votes
Accepted

How to get value of selected page template in Gutenberg editor?

I slightly modified SkyShab's code, because it fired template change event on page load and it didn't fire when template was changed to default (since getEditedPostAttribute( 'template' ) is then '', ...
Lovor's user avatar
  • 901
3 votes

Admin: very slow edit page caused by core meta query

had that issue still in the year 2022 because i have over 10.000 posts and each has 30 meta keys/values. so there is an easy and performant workaround if you insert that piece of code in your ...
Nic Bug's user avatar
  • 231
3 votes
Accepted

Allow editors access to added plugins

Please add the following code. function activate_plugin_name() { $role = get_role( 'editor' ); $role->add_cap( 'manage_options' ); // capability } // Register our activation hook ...
Liz Eipe C's user avatar
3 votes
Accepted

Which PHP page is the Default Posts Page

home.php is the file in the WordPress template hierarchy which is used for the posts page. However, after looking at the Twentyseventeen theme code on GitHub, there is no home.php file provided which ...
Andrew's user avatar
  • 909
3 votes

Gutenberg block editor - list of form components for custom blocks

You can use this Gutenberg handbook for component list - Component List and if you don't want to keep track of what to import from where which component you can use this VSC Extension (I build it) It ...
Ashiquzzaman Kiron's user avatar
3 votes

Add Shortcode inline inside Gutenberg block

They have actually fixed it so you can just add the shortcode within the paragraph content and it works. As simple as ...However, when [expand tag="span" title="this trigger" ...
I'm_With_Stupid's user avatar
3 votes

How to get value of selected page template in Gutenberg editor?

To get this value, use the wp.data module. const template = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'template' ); Since this can be changed in the document settings, you would ...
SkyShab's user avatar
  • 1,404
3 votes

Disable the Code View in the content editor?

You can do it in JavaScript, though the downside is you have to do it block by block. You'll need webpack set up with lodash installed: function removeHtmlEditing( settings, name ) { return ...
WebElaine's user avatar
  • 9,430

Only top scored, non community-wiki answers of a minimum length are eligible