i think you miss the closing > of the opening div tag
<div class="<?php the_sub_field('column_width');?>">
is it possible to edit other settings too?
i had a hook that works for the default wysiwyg.
but not for the acf_wysiwyg-fields. (it looks like my hook is not fully executed)
add_action( 'wp_tiny_mce_init', function () {
?>
<script>
function editShortcut_tiny_mce_init(ed) {
ed.on('init', function () {
// Note these lists may not be complete & that other tinymce plugins can add their own shortcuts anyway.
var ctrls = [ 'u', '1', '2', '3', '4', '5', '6', '7', '8', '9', 's', 'k', 'Alt+F', 'P' ];
var modKeys = [ 'c', 'r', 'l', 'j', 'q', 'u', 'o', 'n', 's', 'm', 'z', 't', 'd', 'h', 'o', 'x', 'a', 'w' ];
// Overwrite shortcuts with no-op function. Key sequences will still be captured.
for (var i = 0; i < ctrls.length; i++ ) {
this.addShortcut('ctrl+' + ctrls[i], '', function () {});
}
for (var i = 0; i < modKeys.length; i++ ) {
this.addShortcut('alt+shift+' + modKeys[i], '', function () {});
}
});
}
</script>
<?php
});
function my_acf_editor( $mceInit, $editor_id ) {
$mceInit['setup'] = 'editShortcut_tiny_mce_init';
// What goes into the 'formatselect' list
$mceInit['block_formats'] = 'Header 3=h3;Header 4=h4;Header 5=h5;Paragraph=p;Code=code';
$mceInit['paste_word_valid_elements'] = '-strong/b,-em/i,-p,-ol,-ul,-li,-h3,-h4,-h5,-h6,-p,-table[width],-tr,-td[colspan|rowspan|width],-th,-thead,-tfoot,-tbody,-a[href|name],br,del';
$mceInit['paste_strip_class_attributes'] = 'all';
$mceInit['toolbar1'] = 'bold,italic,formatselect,bullist,numlist,blockquote,link,unlink,undo,redo';
return $mceInit;
}
add_filter('tiny_mce_before_init', 'my_acf_editor')
i need a solution that works inside function.php or better, inside my custom plugin.
can anyone help me? please.
my aim is: to have a verry simple wysiwyg that only allow things defined by me.
only edit toolbar is not enough, because the user can avoid these restrictions with shortkeys and/or copy&paste from word.
i also would know if it is possible to auto order repeater fields at backend, based on a value inside that repeater (oder by a date-field for example)
at frontend i have no big problem. i do it like this:
foreach( $arr_merge as $key => $row ) {
$thedate = $row['termin_date'];
$column_id[ $key ] = strtotime($thedate);
}
array_multisort( $column_id, SORT_ASC, $arr_merge );
but at backend i dont know, how to do that.
if there where not may repeater rows, manually order is no big thing, but if you have about 10-100 repeater-rows, automatic order would be great. even if it would happen only after a save/update the post, not after add row.
you can use genesis and acf without problems.
probably best is to use custom template.
HowTo: a custom post single or archive template for genesis
<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'your_custom_loop' );
function your_custom_loop() { ?>
<article itemtype="http://schema.org/CreativeWork" itemscope="itemscope" class="post-<?php print $pageid; ?> page type-page status-publish entry">
<div class="entry-content" itemprop="text">
<?php if(have_posts()) : while(have_posts()) : the_post();
echo get_field('my_acf_fields');
endwhile; endif;
?>
</div></article>
<?php }
genesis();
try something like above (of course you need to edit the loop that it fit your needs)
to hide title from backend you can/need to set up a custom post-type that has that setting.
at your “register_post_type” function change/replace/add this line:
'supports' => array('revisions'),
then only revisions shows at backend, no title, no exerpt, wysiwyg, … , leave blank to show nothing except your acf
of course you can use any needed value out of this instead or additional to revisions (list is not complete, look at wp reference)
array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
//add title and alias when a person is created
function my_acf_update_titlevalue( $value, $post_id, $field ) {
global $post;
// vars (title comes from person_name field that is looked for at the filter, after that the alias is generated)
$new_title = $value;
$new_slug = sanitize_title( $new_title );
// update post with the "new" title and alias (because we may hide them at our custom post)
$my_post = array('ID'=> $post_id,'post_title' => $new_title,'post_name' => $new_slug );
wp_update_post( $my_post );
return $value;
}
add_filter('acf/update_value/name=person_name', 'my_acf_update_titlevalue', 10, 3);
try something like above at your plugin: change person_name to your acf field
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.