Here’s my solution B.
// Style the content editor as metabox
function my_content_editor_metabox(){
if (function_exists('get_current_screen')) {
$current_screen = get_current_screen();
if ($current_screen->post_type == 'event')
my_content_editor_metabox_init(__('Description', 'my'));
}
}
add_action('acf/input/admin_footer', 'my_content_editor_metabox');
function my_content_editor_metabox_init($title){
echo
"<script type='text/javascript'>\n".
"jQuery(function($){\n".
"$(function(){\n".
"var editor = $('#postdivrich');\n".
"if (editor.length) {\n".
"editor.addClass('postbox my-content-editor');\n".
"editor.prepend('<div class=\"postbox-header\"><h2>$title</h2></div>');\n".
"}\n".
"});\n".
"});\n".
"</script>\n";
}
Styles:
#acf_after_title-sortables:has(~ #postdivrich.gpi-content-editor){
margin-bottom: 0;
}
#postdivrich.gpi-content-editor{
margin: 20px 0 0;
}
#postdivrich.gpi-content-editor .wp-editor-tools{
background: transparent;
padding-top: 0;
width: 100%;
}
#postdivrich.gpi-content-editor .wp-editor-wrap{
margin: 16px 16px 0;
}
#postdivrich.gpi-content-editor #post-status-info{
width: calc(100% - 32px);
margin: 0 16px 16px;
}
Understood. Thank you!
Seems that nobody found a solution or at least a reasonable explanation why general “Instruction Placement” is ignored in Repeater fields.
Hi @hube2,
Thanks for your help!
I decided to clone the field group and use a copy with Post Object fields on the back-end, and a copy with Text fields on the front-end.
It works great and loads faster, because Select2 script isn’t used.
Hi @hube2,
Thanks, this was helpful.
I need to rephrase my issue and explain it a bit better.
I need to show an ACF form on the front-end to add/edit posts of custom type “Application”. Fields “Job” and “Company” are pre-selected and must be always blocked or marked as read-only (user can’t change them), but I don’t know how I can do it with a Post Object field type (and whether it’s possible at all).
I tried smth like this:
acf.add_action('select2_init', function($input, args, settings, $field){
if ($field.hasClass('application-job')) {
args.disabled = true;
settings.disabled = true;
args.readonly = true;
settings.readonly = true;
}
});
Unfortunately, none of this worked.
On the back-end fields “Job” and “Company” must be enabled and required so an administrator cannot leave them empty.
If you have an idea how I can reach this goal, please share 🙂
As the last possible (alternative) solution I can do the following:
Create another fields group, where both Post Object fields are replaced by Text fields. Text fields can be made read-only very easily. This field group will be shown only on the front-end.
And my task would be just to synchronize them on post update.
I’m not going to edit plugin’s core files. That’s a bad idea!
And honestly I don’t care much about it. But thought it can be good to update ACF plugin so it will show correct title of the default template. If you can please notify developers of this wonderful plugin about this statement.
I thought that ACF support members are more penetrative 🙂
Do you know the purpose of “default_page_template_title” filter?
It changes “Default Template” label to smth else. In my case to “Simple Page”.
Please compare these two screenshots:
http://www.awesomescreenshot.com/image/1024239/853b74f1812a2dfd6c1e7eb62d4e7f17
http://www.awesomescreenshot.com/image/1024240/3dc953d0c7321279a9cda4710003179d
@James, do you think I haven’t done this before starting my topic?
If you can’t reproduce, I can give you access to my test server. How do I have to share credentials?
If anyone wants to put Options page into ie. Appearance menu, use ‘parent_slug’ param.
This feature has been implemented in one of the recent versions.
@emrl, totally agree with you.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.