Hi there,
I tried to add CSS-class-format-buttons for the Visual Editor. It works fine with the Default Editor, but I need them in a Custom Field "WYSIWYG", which is in an repeatable field group.
Can You please help me with this issue?
Thanks, Alex
My Code only works in the Default Editor but not within the one of a repeatable field group:
function kb_mce_buttons_3( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_3', 'kb_mce_buttons_3' );
function kb_mce_before_init_insert_formats( $init_array ) {
$style_formats = array(
// Externer Linkk
array(
'title' => 'Externer Link',
'selector' => 'a',
'classes' => 'externer-link',
),
array(
'title' => 'Interner Link',
'selector' => 'a',
'classes' => 'interner-link',
),
);
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
add_filter( 'tiny_mce_before_init', 'kb_mce_before_init_insert_formats' );
Hello,
I have tried your codes in my localhost with a fresh WP installation + the latest version of Toolset plugins, it does not work in WP Default Editor, I don't see any extra button in the WP Default Editor, please provide detail steps to duplicate the same problem, and take a screenshot for what you are going to achieve.
Hi Luo,
here you can see what happens with the default WP-Editor but not with the Toolset-Editor with this function. Both Screenshots are from the same CPT. The second one is from the default-post-editor-field, the first one is form the repatable fieldgroup underneath. What I need is an easy option to add a style-class to a link in the editor text.
Thanks Alex
I have tried it again in my localhost with a fresh WP installation + the latest version of Toolset plugins, with below steps:
1) Copy/paste your custom codes into theme file functions.php
2) Create a post with classic editor, it does not work in WP Default Editor, I don't see any extra button in the WP Default Editor, see my screenshot: Classic-Editor.JPG
please provide detail steps to duplicate the same problem
If it needs other plugin or theme, please provide downloadable URL for those plugin/theme
Hi,
I did exactly the same an it works. What can i say?
Function in function.php
Can I provide you access? There are no specific Plugins, that can conflict with the editor. I deactivated Visual Composer and it makes no difference.
https://codex.wordpress.org/TinyMCE_Custom_Styles
Since it is a custom codes problem, please provide a copy of your website in below private message box, also point out the problem post URL and where I can edit your PHP codes, I need to test and debug it in my localhost, thanks
I can download the files and download the missing installer.php from your website directly, trying to duplicate the same problem in my localhost, will update here if find anything
I can install your database dump file in a fresh WP installation + the latest version of Toolset plugins, tried these steps:
1) Copy/paste the same codes you mentioned in post into theme file functions.php:
https://toolset.com/forums/topic/custom-mce-button-in-an-repeatable-fieldgroup-field-with-visual-editor-2/#post-1810541
2) Open the post URL you mentioned above:
hidden link
See my screenshot Arbeitsschutz.JPG, there isn't any format select menu in the default WP editor
So please provide a full copy of your website in below private message box.
https://toolset.com/faq/provide-supporters-copy-site/
perhaps you need to open the second button-line:
Thanks for the details, I can see the problem in my localhost, will update here if find anything.
I can duplicate the same problem in my localhost with a fresh WP installation, have escalated this issue, will update here if there is anything news.