【发布时间】:2015-07-07 15:59:49
【问题描述】:
我希望有人能帮助我发现我的错误,因为我在这个问题上浪费了无数个小时。我使用具有灵活内容的高级自定义字段插件模板。我在我目前正在处理的网站上使用具有大量模板的灵活内容字段。我使用了与自定义帖子类型“学位和程序”中的所有帖子显示可选自定义字段相同的策略。我的灵活内容适用于我的所有页面,除了我的单个自定义帖子的页面。我有一个页面“single-degrees-and-programs.php”,其中有:
<?php while (has_sub_field("program_content")): ?>
在我的functions.php中,我已经在我的灵活内容中设置了所有字段,如下所示(希望这里有错误我丢失了,但我对此表示怀疑,因为所有灵活字段都显示在我的自定义管理中帖子。
register_field_group([
'id' => 'acf_program',
'title' => 'Program',
'fields' => [
[
'key' => 'pc000',
'label' => 'Degrees Offered',
'name' => 'degrees_offered',
'type' => 'text',
'instructions' => 'Add the degrees offered',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
],
[
'key' => 'pc0',
'label' => 'Program Content',
'name' => 'program_content',
'type' => 'flexible_content',
'layouts' => [
[
'label' => 'Intro',
'name' => 'intro',
'display' => 'row',
'min' => '',
'max' => '',
'sub_fields' => [
[
'key' => 'pc1',
'label' => 'Heading',
'name' => 'heading',
'type' => 'text',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
],
[
'key' => 'pc2',
'label' => 'Intro Text',
'name' => 'intro_text',
'type' => 'textarea',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'br',
],
],
],
[
'label' => 'Inline Image',
'name' => 'inline_image',
'display' => 'row',
'min' => '',
'max' => '',
'sub_fields' => [
[
'key' => 'pc3',
'label' => 'Image',
'name' => 'image',
'type' => 'image',
'column_width' => '',
'save_format' => 'object',
'preview_size' => 'full',
'library' => 'all',
],
[
'key' => 'pc4',
'label' => 'Caption',
'name' => 'caption',
'type' => 'textarea',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'br',
],
],
],
[
'label' => 'CTA block',
'name' => 'cta_block',
'display' => 'row',
'min' => '',
'max' => '',
'sub_fields' => [
[
'key' => 'pc5',
'label' => 'Block heading',
'name' => 'block_heading',
'type' => 'text',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
],
[
'key' => 'pc6',
'label' => 'Block Text',
'name' => 'block_text',
'type' => 'textarea',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'br',
],
[
'key' => 'pc7',
'label' => 'Block Button',
'name' => 'block_button',
'type' => 'text',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
],
],
],
[
'label' => 'Italic Slab',
'name' => 'italic_slab',
'display' => 'row',
'min' => '',
'max' => '',
'sub_fields' => [
[
'key' => 'pc8',
'label' => 'paragraph',
'name' => 'paragraph',
'type' => 'textarea',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'br',
],
],
],
[
'label' => 'Zip Down Menu',
'name' => 'zip_down_menu',
'display' => 'row',
'min' => '',
'max' => '',
'sub_fields' => [
[
'key' => 'pc9',
'label' => 'Zip Section',
'name' => 'zip_section',
'type' => 'repeater',
'column_width' => '',
'sub_fields' => [
[
'key' => 'pc10',
'label' => 'Title',
'name' => 'title',
'type' => 'text',
'column_width' => '',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
],
[
'key' => 'pc11',
'label' => 'content',
'name' => 'content',
'type' => 'wysiwyg',
'column_width' => '',
'default_value' => '',
'toolbar' => 'full',
'media_upload' => 'yes',
],
],
'row_min' => '',
'row_limit' => '',
'layout' => 'row',
'button_label' => 'Add Row',
],
],
],
],
'button_label' => 'Add Row',
'min' => '',
'max' => '',
],
],
'location' => [
[
[
'param' => 'post_type',
'operator' => '==',
'value' => 'degrees-and-programs',
'order_no' => 0,
'group_no' => 0,
],
],
],
'options' => [
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => [
],
],
'menu_order' => 0,
]);
是否有人对为什么这不起作用有任何意见。我真的需要这方面的帮助。
【问题讨论】:
标签: php wordpress custom-post-type advanced-custom-fields