高级自定义字段是一个免费的WordPress插件,充当自定义字段的GUI层。自定义字段是WP的原生字段,显示在页面,帖子和自定义帖子类型上,但本机自定义字段界面不是非常用户友好。 ACF使用字段组附加字段以编辑屏幕。
我想在标签描述中呈现 acf(高级自定义字段)短代码。虽然其他短代码已成功渲染,但我添加的 acf 短代码似乎不起作用。有人可以吗
如何过滤带有服装字段的服装帖子类型(CPT)以在divi博客模块中显示/隐藏?
我正在尝试使用 Divi 博客模块中的高级服装字段 (ACF) 插件在服装帖子类型 (CPT) 上实现显示/隐藏功能。 我不想只显示那些具有真实价值的 CPT...
我无法检索小部件中高级自定义字段中输入的值。 我正在遵循此处编写的文档,但没有任何运气。 这是我的设置。 在 WordPress 下
条件 ACF 分类法和术语未按预期工作(如果 has_term)
多年来我一直在为此绞尽脑汁,但找不到我想要的解决方案。 在 WordPress 的 archive.php 中,我想要一些条件语句来说明这个 ACF 分类术语是否是这样
在 Woocommerce 订单页面(前台和管理)和电子邮件上显示高级自定义字段
我看到这个问题在下面的帖子中得到了回答,但显然答案已被删除。 在 Woocommerce 订单详细信息和所有电子邮件中显示高级自定义字段值 我希望有人能...
我想通过 wp_insert_post() 函数将数据保存到 ACF 块中。 我的示例数据是一个表,其中“main_text”可能包含换行符、单引号或双引号、链接等 html 标签。 我有一个
我正在尝试从 ACF 组获取值,但无法通过两种方法获取它们: 以下是我的 ACF 字段的设置方式以供参考: 方法一: 我正在尝试从 ACF 获取值group但无法通过两种方法获取它们: 这是我的ACF fields的设置方式供参考: 方法一: <?php $welcome_screen_content = get_field('welcome_screen_content'); // type: group if( $welcome_screen_content ): $title = get_field('title'); endif; echo $title; // prints nothing ?> 方法2: <?php if( have_rows('welcome_screen_content') ): while( have_rows('welcome_screen_content') ): the_row(); $title = get_sub_field('title'); echo $title; // prints nothing endwhile; endif; ?> 在我的帖子模板上,title确实有一个值: 不确定为什么在这两次尝试中,回显 $title 没有任何作用? 在组上使用get_field时,高级自定义字段会返回包含组字段的关联数组。因此,要将标题放入其中,您可以这样做: $welcome_screen_content = get_field('welcome_screen_content'); // type: group if( $welcome_screen_content ): $title = $welcome_screen_content['title']; endif; 方法 1 无法按预期工作,因为 get_field('title') 要求 ACF 获取与“welcome_screen_content”组处于同一级别的字段。 方法 2 无法按预期工作,因为 get_subfield 与 Repeater 或灵活内容字段一起使用。 我遇到了这个辅助函数来从字段组中获取值并发现它很方便。 你可以像这样使用它:get_group_field( '{group field name}', '{sub field name}' );
我正在尝试在两种帖子类型之间进行查询,以构建一个显示 05 新闻的页面。此查询将获取新闻名称、帖子类型“post”以及撰写该新闻的记者姓名...
我有一个大约有 270 行的中继器,我想使用“delete_row()”按索引删除特定的行,我可以很容易地做到这一点,但是有 270 行,这个函数似乎真的很...
使用 Ajax 更新 Wordpress 管理中的 ACF 字段
我有一个问题,我已经尝试解决了一段时间了。在我看来,这项任务与那些使用 ACF 并希望将字段从一篇文章替换到另一篇文章的人相关。有人马...
我希望实现与本文所述相同的功能:https://support.advancedcustomfields.com/forums/topic/order-by-sorting-in-relationship-field/ 如上链接所示,我是
如果选择了一个组,如何创建元素或小部件以获取特定位置的所有组?
如何获取特定位置的所有 ACF 组,然后如果选择了一个组,则使用 AJAX 和 jQuery 获取其字段? 任何人都请帮助我,我将非常感激 如何获取特定位置的所有 ACF 组,然后如果选择了一个组,则使用 AJAX 和 jQuery 获取其字段? 任何人请帮助我,我将非常感激 <?php if ( !defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Elementor_List_Widget extends\ Elementor\ Widget_Base { public function get_name() { return 'elementor-acf-fields'; } public function get_title() { return __( 'acf groups and fields', 'elementor-acf-fields' ); } public function get_icon() { return 'eicon-editor-code'; } public function get_categories() { return [ 'General' ]; } protected function _register_controls() { $all_groups = get_groups(); $get_fields = get_acf_fields(); $this->start_controls_section( 'section_acf_fields', [ 'label' => __( 'ACF Fields', 'elementor-acf-fields' ), ] ); $this->add_control( 'acf_groups', [ 'label' => __( 'ACF Groups', 'elementor-acf-fields' ), 'type' => \Elementor\ Controls_Manager::SELECT, 'groups' => $all_groups, 'default' => '', 'label_block' => true, 'ajax' => [ 'callback' => [ $this, 'get_acf_fields' ], 'event' => 'change', ], ] ); $this->add_control( 'acf_fields', [ 'label' => __( 'ACF Fields', 'elementor-acf-fields' ), 'type' => \Elementor\ Controls_Manager::SELECT, 'options' => $second_variable, 'default' => '', 'label_block' => true, ] ); $this->end_controls_section(); } public function get_acf_fields( $request ) { $group_id = $request[ 'group_id' ]; $fields = []; if ( function_exists( 'acf_get_fields' ) ) { $acf_fields = acf_get_fields( $group_id ); if ( $acf_fields ) { foreach ( $acf_fields as $field ) { $fields[ $field[ 'key' ] ] = $field[ 'label' ]; } } } return [ 'options' => $fields, ]; } public function get_groups() { if ( function_exists( 'acf_get_field_groups' ) ) { $acf_groups = \acf_get_field_groups(); } else { $acf_groups = \apply_filters( 'acf/get_field_groups', [] ); } $specifications_group_id = $acf_groups; // Post ID of the specifications field group. $specifications_fields = array(); $fields = acf_get_fields( $specifications_group_id ); foreach ( $fields as $field ) { $field_value = get_field( $field['name'] ); if ( $field_value && !empty( $field_value ) ) { $specifications_fields[$field['name']] = $field; $specifications_fields[$field['name']]['value'] = $field_value; } } return $specifications_fields; } protected function render() {} } 选择一个选项时,根据其自定义位置在下拉列表中获取所有 acf 组的答案,然后其字段将显示,请参见下面的代码。为此,我创建了名为“jpro_acf_group_select2”的自定义元素控件 <?php /** * Elementor currency control. * * A control for displaying a select field with the ability to choose currencies. * * @since 1.0.0 */ class Elementor_Jobpro_ACF_Group_Select2_Control extends \Elementor\Base_Data_Control { /** * Get currency control type. * * Retrieve the control type, in this case `currency`. * * @since 1.0.0 * @access public * @return string Control type. */ public function get_type() { return 'jpro_acf_group_select2'; } public function enqueue() { //wp_enqueue_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js', array( 'jquery' ), '4.0.13', true ); wp_register_script( 'elementor-group-scripts', get_plugin_url( '/assets/js/elementor-group-scripts.js'), [ 'jquery-elementor-select2' ], '1.0.0' ); //wp_register_script( 'elementor-group-scripts', get_plugin_url( '/assets/js/elementor-group-scripts.js'), [ 'select2' ], '1.0.0' ); wp_enqueue_script( 'elementor-group-scripts' ); $jobpro_plugin_arr = array( 'site_url' => home_url('/'), 'ajax_url' => home_url('/?jobpro_settings=1'), 'error_msg' => esc_html__('There is some problem.', 'jobpro-employement-verification'), ); wp_localize_script('elementor-group-scripts', 'jobpro_plugin_data', $jobpro_plugin_arr); } public function get_value( $control, $settings ) { if ( isset( $settings[ $control['name'] ] ) ) { $group_item = $settings[ $control['name'] ]; } else { $group_item = $control['default']; } return $group_item; } /** * Render currency control output in the editor. * * Used to generate the control HTML in the editor using Underscore JS * template. The variables for the class are available using `data` JS * object. * * @since 1.0.0 * @access public */ public function content_template() { $control_uid = $this->get_control_uid(); ?> <div class="elementor-control-input-wrapper"> <select id="<?php echo $control_uid; ?>" class="elementor-select2 jobpro-resume-group-select2 {{{ data.class }}}" type="select2"data-setting="{{ data.name }}"> <# var printOptions = function( options ) { _.each( options, function( option_title, option_value ) { #> <?php // If the option title is array of title & icon. ?> <option value="{{ option_value }}">{{{ option_title?.title || option_title }}}</option> <# } ); }; if ( data.groups ) { for ( var groupIndex in data.groups ) { var groupArgs = data.groups[ groupIndex ]; if ( groupArgs.options ) { #> <optgroup label="{{ groupArgs.label }}"> <# printOptions( groupArgs.options ) #> </optgroup> <# } else if ( _.isString( groupArgs ) ) { #> <option value="{{ groupIndex }}">{{{ groupArgs }}}</option> <# } } } else { printOptions( data.options ); } #> </select> </div> <# if ( data.description ) { #> <div class="elementor-control-field-description">{{{ data.description }}} </div> <# } #> <?php } } 下面是它的js和ajax // Wait for the Elementor editor to load jQuery(window).on('elementor:init', function () { // Add custom control JS to the widget edit mode elementor.hooks.addAction('panel/open_editor/widget', function (panel, model, view) { // Check if the current widget is our custom widget if (model.get('widgetType') === 'resume-listings') { jQuery('.jobpro-resume-group-select2').select2({ width: '100%', allowClear: true, placeholder :'Select Group', }); var widgetType = model.get( 'widgetType' ); var settings = model.get('settings'); var $element = jQuery('#elementor-panel-page-editor').find('.jobpro-group-key'); var settings_attributes = settings.attributes; var select_resume_group = settings.attributes.select_resume_group; if(select_resume_group == 'undefined'){ select_resume_group = jQuery('.jobpro-resume-group-select2').val(); } var $fields_element = jQuery('#elementor-panel-page-editor').find('.jobpro-acf-group-fields-select2'); if(select_resume_group){ if ( $element.length ) { $element.val(select_resume_group); } if ( $fields_element.length ) { $fields_element.data('group_item', select_resume_group); jobpro_resume_group_fields_(settings_attributes, $fields_element, select_resume_group); } } jQuery(document).on('change', '.jobpro-resume-group-select2',function (e) { select_resume_group = jQuery(this).val(); $element.val(select_resume_group); $fields_element.data('group_item', select_resume_group); $fields_element.val('').trigger('change'); jobpro_resume_group_fields_(settings_attributes, $fields_element, select_resume_group); }); function jobpro_resume_group_fields_(settings_attributes, $fields_element, select_resume_group){ jQuery.ajax({ type: "GET", dataType: "json", url: jobpro_plugin_data.site_url+'wp-json/wp/v1/jobpro-get-group-fields', data: { search: '', verification_group: select_resume_group, }, success: function(data) { if (data.status == 'success') { $fields_element.find('option:not(:first)').remove(); jQuery.each(data.results, function(index, option) { $fields_element.append(jQuery('<option>').text(option.text).attr('value', option.id)); }); $fields_element.each(function() { var currentElement = jQuery(this); let dropdownName = currentElement.attr('name'); if(dropdownName == 'undefined'){ dropdownName = currentElement.data('setting'); } dropdownName = currentElement.data('setting'); if(dropdownName !== 'undefined'){ var keyValue = settings_attributes[dropdownName]; currentElement.val(keyValue).trigger('change'); } }); } }, error: function(jqXHR, textStatus, errorThrown) { console.error(errorThrown); } }); } $fields_element.select2({ width: '100%', allowClear: true, placeholder :'Select Group Fields', //minimumInputLength: 3, tags: false, ajax: { data: function (params) { if ( select_resume_group.length < 1 || select_resume_group == 'undefined') { select_resume_group = jQuery('.jobpro-resume-group-select2').val(); } var query = { search: params.term, verification_group: select_resume_group } return query; }, url: jobpro_plugin_data.site_url+'wp-json/wp/v1/jobpro-get-group-fields', dataType: 'json', cache: true, } }); } }); }); 下面是ajax public function jobpro_load_group_fields(){ $search = !empty($_GET['search']) ? sanitize_text_field($_GET['search']) : ''; $verification_group = !empty($_GET['verification_group']) ? sanitize_text_field($_GET['verification_group']) : ''; $acf_group_object = get_field_object($verification_group); $verification_group_fields = !empty($acf_group_object['sub_fields']) ? $acf_group_object['sub_fields'] : ''; $responsedata = array(); $responsedata['status'] = 'success'; $responsedata['results'] = array(); foreach ($verification_group_fields as $field) { $name = isset($field['name']) ? $field['name'] : ''; $label = isset($field['label']) ? $field['label'] : ''; $responsedata['results'][] = array('id' => $name, 'text' => $label); } wp_send_json($responsedata); }
嘿!我们可以使用 JAVA 创建 Sci fi Advance UI 吗?我的意思是用java编程是可能的吗? [关闭]
我想使用 JAVA 编程创建一个高级用户界面,就像一个超级未来的界面,你可以认为它就像 2100 年或 2150 年的软件界面。谁能给我或建议我...
我在 woocommerce“查看订单”页面中使用 acf_form()(高级自定义字段前端表单)创建了一个前端表单,允许客户为我们上传一些文件,该表单适用于
我在使用 ACF 文件字段类型在高级自定义字段扩展 P 上启用“允许多个文件”的 WordPress 帖子上显示多个文件(.pdf、.docx、.xlsx 等)时遇到问题...
我目前有一些工作 jQuery,每 3.5 秒重新加载一次内容。但是,我想知道是否有可能做到这一点,以便在 WordPress 中更新页面时,只有相关的
我正在使用 Woocommerce、片段和 ACF 字段,我在产品中创建了元字段,我想在购物车项目中获取 ACF 字段,并将它们保存在订单表中但不起作用,我已经检查了巨大的
我使用 Advanced Custom Field Pro 插件创建了一些自定义字段,如何在我的 woocommerce 订单中显示这些字段?
我想在 Frontend 的顺序和 Backends 的顺序中看到。如果有一个插件解决方案对我来说更好 我使用了 php 代码,但我不知道出了什么问题。我不明白。我想用...
我已经按照本文档 https://www.advancedcustomfields.com/resources/creating-a-new-field-type/ 创建了自定义字段类型,我有以下字段: YouTube ID(输入类型文本) 提交 ...
ACF 自定义字段类型,'input_admin_enqueue_scripts' 回调函数未触发
我正在使用他们的模板,按照他们在此处推荐的方式创建我的自定义字段类型:https://www.advancedcustomfields.com/resources/creating-a-new-field-type/ 这是我的场景,我想...