Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

topic

  • Unread

    Limit search results to ACF post type and category?

    I’ve set up an ACF post type called “encyclopedia” with a taxonomy category called “topics.” I now want to create an Elementor search results page that will only show post types of “encyclopedia” with the category of “topic.” I’ve tried making a PHP filter to restrict results to that criteria, but it’s still showing all entries that contain the entered search term from across the entire site.

    Below is the code to show any encyclopedia entries that meet the search criteria, but it’s showing all entries that contain the entered search criteria.

    Any suggestions for what I need to do differently?

    Thanks in advance for your help.

    if (!is_admin()) {
    function mv_search_filter($query) {
    if ($query->is_search) {
    $query->set('post_type', array( 'encyclopedia' ));
    }
    return $query;
    }
    add_filter('pre_get_posts','mv_search_filter');
    }

  • Helping

    Issue with Elementor Pro

    I have a problem on a website between Elementor Pro and ACF pro. It seems to be with the photo galleries, but I’m not sure. The error that appears is the following:

    PHP: 2024-08-02 13:43:19 [error X 3][/var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor-pro/modules/dynamic-tags/acf/tags/acf-gallery.php::48] Uncaught TypeError: Cannot access offset of type string on string in /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor-pro/modules/dynamic-tags/acf/tags/acf-gallery.php:48
    Stack trace:
    #0 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/data-tag.php(44): ElementorPro\Modules\DynamicTags\ACF\Tags\ACF_Gallery->get_value()
    #1 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/manager.php(216): Elementor\Core\DynamicTags\Data_Tag->get_content()
    #2 [internal function]: Elementor\Core\DynamicTags\Manager->get_tag_data_content()
    #3 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/manager.php(109): call_user_func_array()
    #4 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/manager.php(70): Elementor\Core\DynamicTags\Manager->parse_tag_text()
    #5 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/controls/base-data.php(91): Elementor\Core\DynamicTags\Manager->parse_tags_text()
    #6 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/controls-stack.php(1329): Elementor\Base_Data_Control->parse_tags()
    #7 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/controls-stack.php(1176): Elementor\Controls_Stack->parse_dynamic_settings()
    #8 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/post.php(298): Elementor\Controls_Stack->get_parsed_dynamic_settings()
    #9 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/dynamic-css.php(36): Elementor\Core\Files\CSS\Post->render_styles()
    #10 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/dynamic-css.php(40): Elementor\Core\DynamicTags\Dynamic_CSS->render_styles()
    #11 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/post.php(178): Elementor\Core\DynamicTags\Dynamic_CSS->render_styles()
    #12 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/base.php(680): Elementor\Core\Files\CSS\Post->render_css()
    #13 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/base.php(180): Elementor\Core\Files\CSS\Base->parse_content()
    #14 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/base.php(131): Elementor\Core\Files\Base->update_file()
    #15 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/base.php(227): Elementor\Core\Files\CSS\Base->update()
    #16 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/post.php(201): Elementor\Core\Files\CSS\Base->enqueue()
    #17 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/dynamic-tags/manager.php(488): Elementor\Core\Files\CSS\Post->enqueue()
    #18 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp-hook.php(324): Elementor\Core\DynamicTags\Manager->after_enqueue_post_css()
    #19 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #20 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/plugin.php(517): WP_Hook->do_action()
    #21 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/base.php(274): do_action()
    #22 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/files/css/post.php(201): Elementor\Core\Files\CSS\Base->enqueue()
    #23 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/frontend.php(1134): Elementor\Core\Files\CSS\Post->enqueue()
    #24 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/jet-tabs/includes/addons/jet-accordion-widget.php(1071): Elementor\Frontend->get_builder_content()
    #25 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/controls-stack.php(2325): Elementor\Jet_Accordion_Widget->render()
    #26 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/widget-base.php(635): Elementor\Controls_Stack->render_by_mode()
    #27 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/widget-base.php(776): Elementor\Widget_Base->render_content()
    #28 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Widget_Base->print_content()
    #29 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(1422): Elementor\Element_Base->print_element()
    #30 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Element_Base->print_content()
    #31 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(1422): Elementor\Element_Base->print_element()
    #32 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Element_Base->print_content()
    #33 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(1422): Elementor\Element_Base->print_element()
    #34 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Element_Base->print_content()
    #35 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/base/document.php(1875): Elementor\Element_Base->print_element()
    #36 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/base/document.php(1800): Elementor\Core\Base\Document->do_print_elements()
    #37 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/core/base/document.php(1201): Elementor\Core\Base\Document->print_elements()
    #38 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/frontend.php(1158): Elementor\Core\Base\Document->print_elements_with_wrapper()
    #39 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-content/plugins/elementor/includes/frontend.php(1053): Elementor\Frontend->get_builder_content()
    #40 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp-hook.php(324): Elementor\Frontend->apply_builder_in_content()
    #41 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/plugin.php(205): WP_Hook->apply_filters()
    #42 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1871): apply_filters()
    #43 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(958): WP_REST_Posts_Controller->prepare_item_for_response()
    #44 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api/class-wp-rest-server.php(1230): WP_REST_Posts_Controller->update_item()
    #45 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api/class-wp-rest-server.php(1063): WP_REST_Server->respond_to_request()
    #46 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch()
    #47 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/rest-api.php(420): WP_REST_Server->serve_request()
    #48 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp-hook.php(324): rest_api_loaded()
    #49 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #50 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/plugin.php(565): WP_Hook->do_action()
    #51 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp.php(418): do_action_ref_array()
    #52 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/class-wp.php(813): WP->parse_request()
    #53 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-includes/functions.php(1336): WP->main()
    #54 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/wp-blog-header.php(16): wp()
    #55 /var/www/vhosts/eltallerdeverdes.com/003.eltallerdeverdes.com/index.php(17): require(‘…’)
    #56 {main}

  • Unread

    Repeater field doesn’t work with only one entry

    I’ve created an options page and on that page I attached a repeater field with one link field in it.

    The repeater field on the options page is called: featured_links.
    The subfield is called ftlink and it returns an array.

    My code to view the fields is this:

    function uplvl_favlist () {
        if ( get_field( 'featured_links', 'option' ) ) {
            $links = '<div class="favLinks">';
    
            //check if there are external links
            if ( have_rows( 'featured_links', 'option' ) ):
                while ( have_rows( 'featured_links', 'option' ) ) : the_row();
                    $link = get_sub_field('ftlink');
                    $url = $link['url'];
                    $title = $link['title'];
                    $target = $link['target'] ? $link['target'] : '_self';
                    $links .='<a href="'.esc_url($url).'" target="'. esc_attr( $target ) .'" rel="noopener">'.esc_html($title).'</a>';
                endwhile;
            endif;
            $links .= '</div>';
            
            return $links;
        } else {
            return;
        }
    }
    add_shortcode('fav-list', 'uplvl_favList');

    If on the options page I enter just one link (url:https://example.com title: example), I get an error:
    Uncaught Error: Cannot access offset of type string on string
    referencing $link = get_sub_field('ftlink');

    however if I add 2nd row entry to the field the code returns as expected 2 links.

    What am I doing incorrectly?

  • Solving

    Query Loop Single Post Popup Modal

    I’ve created a custom post type in ACF and displayed that on the front end using the Query Loop block. I’m using the Gutenberg editor in the 2024 theme. The default behavior is when a post in the loop is clicked it opens the single post page but what I would like is to have the single post page open in a popup modal. Does anyone know how I can do this? Is it possible to apply a data-id to the ACF posts in the loop grid so I can add some PHP/JS to make it open in a modal?

  • Helping

    Can’t read data from ACF during import with WP All Import

    Can’t read data from ACF during import with WP All Import

    Hey everyone,

    First of all, I already asked the WP All Import Pro Support to help me but they had no idea and they “do not give any support to custom code”. So I really hope I can get some help here.

    I am importing a .csv file with products to my WooCommerce shop and I have a custom function that saves a json string to an acf field. (I have to save pairs of sizes for a products with a unique url for each size.)

    This is pretty straight forward and saving a string to the field works just fine but I do not get any value when I try to read from the same ACF Field so at the end of the import I only have the latest size/url pair in the json string saved.

    I tried to use get_field as well as get_post_meta, but it’s the same problem with both functions – no data.

    I am almost sure that it did work a couple of weeks ago when I first wrote the script but some update broke it and I have no idea how to fix it rn.

    Here is the code:

    <?php
    function update_product_sizes($post_id, $data ) {
    
        // The current data row from the imported .csv
        $row = json_decode(json_encode((array) $data), true);
        $size = $row["size"];
        $affiliate_url = $row["link"];
        $product_name = $row["title"];
    
        // Der ACF Field Key mit den Daten Groesse und URL
        $field_key = "field_6628d713e57dd"; // Replace with the actual field key for your ACF field
    
        // Step 1: Retrieve the ACF field value (JSON data)
        $json_data = get_field($field_key, $post_id);
        //$json_data = get_post_meta($post_id,$field_key,true);
    
        ob_start();
        print_r($json_data);
        $output = ob_get_clean();
    
        add_log_msg("Retreived ACF Data: " . $output . ", PostID: " . $post_id . "<br />");
    
        // Step 2: Decode the JSON data into a PHP array
        $data_array = $json_data ? json_decode($json_data, true) : array();
    
        // Step 3: Define the new size and URL to be added
        $new_entry = array(
            'size' => $size,  // size
            'url' => $affiliate_url  // Affiliate URL
        );
    
        // Step 4: Add the new entry to the array
        $data_array[] = $new_entry;
    
        // Step 5: Encode the PHP array back to JSON
        $new_json_data = json_encode($data_array);
    
        // Step 6: Update the field with the new JSON data
        $update = update_field($field_key, $new_json_data, $post_id);
    
        if($update) {
            $log_msg = "New Size and URL added for product: " . $product_name . ", Size: ". $size .", URL: ". $affiliate_url . ", data: ". $new_json_data . ", post ID: ". $post_id . ", Field Key: ". $field_key . "<br/>";
            add_log_msg($log_msg);        
        } else {
            $log_msg = "Update failed.";
            add_log_msg($log_msg);    
        }
    
    }
    
    // Hook into WP All Import
    add_action('pmxi_saved_post', 'update_product_sizes', 10, 2);
    
    function add_log_msg($m) {
        printf("[%s] %s", date("H:i:s"), $m);
        flush();
    }
    
    ?>

    Any help or hints on what to try is very much appreciated. Thanks!

  • Unread

    Update post object field after changing taxonomy names

    Márcio Bento

    Jul 22, 2024, 8:13 AM CDT

    Hi there,

    I created a taxonomy that is global across all custom post types on our website. The taxonomy is ‘Languages’

    We had: English, portuguese, French, Spanish, etc.

    Now the client wanted to change to the native way of writing those languages: English, Português, Français, Español.

    We already changed these names. However, we have a post object field that uses this taxomy. And those are still displaying the old names. How can we quickly update this so the changes take effect? (Without having to go inside one by one and hit update)

  • Solving

    Multisite and changing how the ‘users’ field works

    I am using a ‘users’ field on site 2 called ‘speakers_name’, but I don’t want it to search for users. I want it to search through posts on a CPT on site 1 called ‘speakers’.

    I have the below, but it is just listing users on site 2

    function populate_users_field_with_speakers($field) {
        // Switch to Site 1
        $site_1_id = 1; // Replace with your Site 1 ID
        switch_to_blog($site_1_id);
    
        // Fetch all speakers
        $args = array(
            'post_type' => 'speakers',
            'post_status' => 'publish',
            'posts_per_page' => -1
        );
    
        $speakers_query = new WP_Query($args);
    
        // Reset choices
        $field['choices'] = array();
    
        // Loop through speakers and add to field choices
        if ($speakers_query->have_posts()) {
            while ($speakers_query->have_posts()) {
                $speakers_query->the_post();
                $field['choices'][get_the_ID()] = get_the_title();
            }
            wp_reset_postdata();
        }
    
        // Restore to current blog (Site 2)
        restore_current_blog();
    
        return $field;
    }
    add_filter('acf/load_field/name=speakers_name', 'populate_users_field_with_speakers');

    What am I missing?

  • Helping

    Select Field with advanced ‘logic’, groups and search

    First i will try to explain my actual code situation and the resulting problem:

    In my application i use a group of three select fields for “text content”.

    field 1 for title
    field 2 for subtitle
    field 3 for details

    All fields use the same choices base. To avoid that the user males the same selection in two or more fields of the group i use the ACG JavaScript API with ‘select2_ajax_results’ and disable the option if it’s selected in another field of the group.

    This works like a charm.

    else if(instance.data.field.data.key === 'field_dpf_settings_presentation_label_subtitle_content') {
    var pf_options = json.results;
    $(pf_options).each(function() {
    if($.inArray(this.id.toString(), dpf_title.val()) !== -1) {
    this.disabled = true;
    this.text = this.text + ' (' + acf.__('used in title') + ')';
    }
    else if($.inArray(this.id.toString(), dpf_details.val()) !== -1) {
    this.disabled = true;
    this.text = this.text + ' (' + acf.__('Used in details') + ')';
    }
    else {
    this.disabled = false;
    }
    });
    }

    Now i tried to get “optgroups” working and all hacks and tips here in the forum doesn’t work because it depends and static values and not possible with AJAX.

    So i decided to extend my JS code and “rebuild” the json.result array to include the optgroups. Also this i could get working.

    var pf_options = json.results;
    var neu = [];
    var counter = -1;
    $(pf_options).each(function() {
    var element = this.id;
    if ( element.search('#') !== -1 ) {
    element = element.replace("#", "");
    neu.push( { 'text' : this.text, 'children' : [] } );
    counter++;
    } else {
    id = this.id;
    text = this.text;
    neu[counter]['children'].push( { 'id' : id, 'text' : text } );
    }
    });

    The result are optgroups – OK – Now i tried to serach for an element and now i get an JS error in translation and no result and only no result in untranslated variant. Always the “children” element gets a reading error and value to undefined.

    Could someone help?

    And the end i have to say that it was more than good if an optgroup would be possible by default after more than ten years of questions about this here. But for me it would work with a hacking tip also.

    Regards André

  • Unread

    Getting custom flexible content field from post object

    Hello all,
    I am using the Post Object field to choose a post which is displayed on another page.

    The documentation explains how to get value from a custom field like so:

    
    $featured_posts = get_field('featured_posts');
    $custom_field = get_field( 'field_name', $featured_post->ID );

    But, the post uses flexible content fields, so this doesn’t work since the fields are sub_fields of the flexible content fields.

    Question: how to get the value from my custom field?
    Thanks!

  • Unread

    Datepicker Error When ACF and Advanced Schedule Posts Used Together

    I am using Advanced Custom Fields (Version 6.3.3) on my WordPress (version 6.5.5) website. I am also using Advanced Schedule Posts (Version 2.1.8 from https://github.com/hijiriworld/advanced-schedule-posts) on this website. These two plugins have worked together in the past but with the latest versions of WordPress and the plugins they no longer work for datepicker.

    With Advanced Custom Fields ACTIVATED and Advanced Schedule Posts ACTIVATED
    – Advanced Custom Fields datepicker fails to work
    – Advanced Schedule Posts datepicker fails to work

    With Advanced Custom Fields ACTIVATED and Advanced Schedule Posts DEACTIVATED
    – ACF datepicker works correctly

    With Advanced Custom Fields DEACTIVATED and Advanced Schedule Posts ACTIVATED
    – Advanced Schedule Posts datepicker works correctly

    The console error I get when trying to use the ACF datepicker or Advanced Schedule Posts datepicker in the WordPress admin is below,

    Uncaught TypeError: $(…).zIndex is not a function
    at HTMLInputElement._showDatepicker (jquery.datePicker.min.js?ver=e95bb7bd8a621b465f58e64aa952b821:746:31)
    at HTMLInputElement.dispatch (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=e95bb7bd8a621b465f58e64aa952b821:2:40035)
    at v.handle (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=e95bb7bd8a621b465f58e64aa952b821:2:38006)

  • Helping

    ACF Pro Checkbox Bug? Expects args[‘disabled’] to be an array but it’s 0.

    I’m having issues adding checkbox fields with hard-coded choices (in admin).

    Every time I add a checkbox and adding the choices in admin, I’m getting this error:

    array_map(): Argument #2 ($array) must be of type array, int given

    Checkboxes added using taxonomy field are fine.

    In:
    /advanced-custom-fields-pro/includes/fields/class-acf-field-checkbox.php:247

    This is the code:
    $args[‘disabled’] = array_map( ‘esc_attr’, $args[‘disabled’] );

    ($args[‘disabled’] is 0)

    Here’s the field.:

    {
    “key”: “field_65e14ce0816cf”,
    “label”: “Charts Reporting To”,
    “name”: “charts_reporting_to”,
    “aria-label”: “”,
    “type”: “checkbox”,
    “instructions”: “”,
    “required”: 0,
    “conditional_logic”: 0,
    “wrapper”: {
    “width”: “”,
    “class”: “”,
    “id”: “”
    },
    “disabled”: 0,
    “relevanssi_exclude”: 0,
    “choices”: {
    “Country Aircheck”: “Country Aircheck”,
    “Music Row”: “Music Row”,
    “AMA”: “AMA”,
    “Roots Music Report”: “Roots Music Report”,
    “Bluegrass Unlimited Survey”: “Bluegrass Unlimited Survey”,
    “Bluegrass Today Bluegrass”: “Bluegrass Today Bluegrass”,
    “Bluegrass Today Grassicana”: “Bluegrass Today Grassicana”,
    “Bluegrass Today Gospel”: “Bluegrass Today Gospel”,
    “Singing News”: “Singing News”,
    “Singing News Bluegrass”: “Singing News Bluegrass”
    },
    “default_value”: [],
    “return_format”: “value”,
    “allow_custom”: 1,
    “save_custom”: 0,
    “layout”: “vertical”,
    “toggle”: 0,
    “custom_choice_button_text”: “Add new choice”
    },

    I noticed all ACF fields have disabled set to zero.

    Any help is appreciated.

  • Unread

    Custom Block with flexible content fields not working

    Can’t seem to get flexible content to work in ACF Blocks Gutenberg. The block and fields appear on edit. But do not draw on the editor or preview page. The page seems to get caught in a loop and times out. I have other custom ACF blocks working fine but flexible content is causing issues.

    I have ACF fields registered:
    > notice_type, type: flexible content
    > Important, type Layout
    > notice_important, type text
    > Show this field group if block is equal to : notices

    Registered block: register_block_type( get_template_directory() . ‘/acf-blocks/notices’ );

    Block json is:
    {
    “name”: “acf/notices”,
    “title”: “Notices”,
    “description”: “callouts alerts and buttons”,
    “style”: [ “file:../../css/style.css” ],
    “category”: “campus-blocks”,
    “icon”: “chart-line”,
    “keywords”: [“notice”, “notes alerts warnings info”],
    “acf”: {
    “mode”: “auto”,
    “renderTemplate”: “notices.php”
    },
    “supports”: {
    “anchor”: false
    }
    }

    Notices.php:
    <div class=”row”>
    <div class=”col-12 col-lg-12 col-xl-6 page-content”>
    <div class=”notice”>
    <?php
    if ( have_rows( ‘notice_type’ ) ) {
    while ( have_rows( ‘notice_type’ ) ) {
    if ( get_row_layout() == ‘important’ ) {
    the_sub_field(‘notice_important’);
    }
    }
    };
    ?>
    </div>
    </div>
    </div>

  • Unread

    Posts arent connecting to Post Grid

    I am trying to setup a word press site to list available animals for an animal rescue. I have the pages set up and i have created a custom post type as well ad custom fields with the Advanced Custom Fields plugin. The fields have things like name, bio, age and a picture. no title is required. i have the Spectra editor installed and have added the Post Grid block to the page and connected the post grid to the available animals post type but the posts are not displaying

    The post type in ACF is public and active and adding a new post works and i can go back and review the data. I just am not seeing the post display in a grid on the page.

  • Solving

    Set up a single post meta with the field Group

    Hi, is it possible with the Group field to enter all internal fields as values of the Group field?

    Currently ACF creates a field for each metabox, but I would like to end up with a single post meta in the database with all the article values in it.

    I need them to set the article template of my custom theme.

    I want to reduce the number of database queries to a single query and take advantage of the longtext of the meta_value field at this point.

    Any information is really appreciated, thank you very much.

  • Unread

    No indicator for blocks missing required fields?

    Hello,

    Many customers are annoyed and battling with required fields blocking saving of pages.

    When is an indicator in the edit field being added that there are missing required fields?

    This should be quite a high priority. 😅😅

  • Helping

    WPForms and ACF

    Hey!
    I got a question: I have a WPForms Form with a few (like 20?!) select fields with dynamic data, fetched from ACF Post Types (for example “Apple” with different types of Apples).
    When I send the form, it only transmits the id of the field but not the name. What can I do?
    thanks in advance a lot!

  • Unread

    I’m sure there’s a quick fix

    Hi! I’m new to ACF, and I’m sure there is a simple fix for what I need!

    For my Archives page, each item is getting wrapped as it’s own DIV, so the grid isn’t working (should be displaying 2 items per row), and my ‘order’ => ‘ASC’ isn’t working.

    Here’s the archive in question (only two posts so far to draw from):
    https://english.flywheelsites.com/directory/administrative-faculty/

    functions.php is attached

  • Unread

    Escape WYSIWYG Editor

    I know this is a basic question, but do I need to escape the WISIWYG editor return before echoing?

    I see that it is run through acf_the_content and I think that is already doing this but I just want to be sure. I’m not trying to filter anything additional out of the content.

    Thanks

  • Unread

    Long Database Query causing Local Push Issue?

    I use WP Engine for hosting and the Local app for development. Recently I’ve been having difficulty pushing my local site up to WPE. When it comes time to “Dump database and push” Local just hangs..sometimes as long as 20+ minutes before I end up having to kill the app. I was working with WPE support last evening and the support member shared this information though I don’t know that it’s actually what is causing the issue with pushing from Local.

    “From what I’m seeing at the server level, Advanced Custom Fields Pro appears to be generating a long database query.
    We could try disabling the server’s Long Process Killer (LPK) in the event that the long database query is keeping the push from completing.”

    WordPress database error Table 'wp_olcfdev.wp_posts' doesn't exist for query SELECT wp_posts.ID#012#011#011#011#011#011 FROM wp_posts #012#011#011#011#011#011 WHERE 1=1 AND wp_posts.post_type = 'acf-ui-options-page' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))#012#011#011#011#011#011 #012#011#011#011#011#011 ORDER BY wp_posts.menu_order ASC, wp_posts.post_title ASC#012#011#011#011#011#011 /* From [olcfdev.wpengine.com/wp-admin/] in [/nas/content/live/olcfdev/wp-content/plugins/advanced-custom-fields-pro/includes/class-acf-internal-post-type.php:397] */ made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, ACF->init, do_action('acf/init'), WP_Hook->do_action, WP_Hook->apply_filters, ACF_UI_Options_Page->register_ui_options_pages, ACF_Internal_Post_Type->get_posts, ACF_Internal_Post_Type->get_raw_posts, get_posts, WP_Query->query, WP_Query->get_posts

    My question is does this look normal and likely not the cause of my push issues??

  • Unread

    Using “update_field” to update a group

    Apologies if what I’m asking about is ACF 101. I’m kind of new when it comes to programmatically updating field values. My problem concerns a site that is using ACF Pro (version 6.3.3). I have a custom post type called “Projects” that is registered through theme code. I’ve created over 100 projects, each with their own featured image (using the built-in WP featured image field). Now, the client wants the ability to have multiple featured images, one for each “discipline” (a custom taxonomy I created for them). There are three disciplines, one of which is called “Architecture”. They want to show a different featured image for each project on the frontend, depending on which discipline term has been selected by the user. To that end, I have created a group called “discipline_imgs” with 3 image sub-fields. Each sub-field’s field name corresponds to a discipline term slug. For example, there’s an image sub-field labelled “Architecture” with the field name “architecture”. Each image sub-field is set to return the image ID.

    They want to copy the current featured image in each project to the “architecture” image sub-field, and then they want the other sub-fields updated with different images. So, rather than going through all 115 projects and manually copying the featured image over, I decided to write a script to do it. The script is in the form of a theme page template. Here is the template code:

    <?php

    /**
    * Template Name: Copy Project Featured Image to Architecture Image
    */

    defined('ABSPATH') || die(1);
    is_super_admin() || die(1);

    header('Content-Type: text/plain; charset=' . get_bloginfo('charset'));

    query_posts(
    [
    'post_type' => 'project',
    'posts_per_page' => -1,
    ],
    );
    $project_count = $project_updated_count = 0;
    while (have_posts()) :
    the_post();
    ++$project_count;
    [
    'architecture' => $architecture_img,
    ] = (array)get_field('discipline_imgs');
    var_dump(compact('architecture_img'));

    if (0 < $architecture_img) :
    continue;
    endif;

    $featured_img = get_post_thumbnail_id();
    var_dump(compact('featured_img'));

    if (!$featured_img) :
    continue;
    endif;

    $result = update_field(
    'discipline_imgs',
    ['architecture' => $featured_img],
    );

    if ($result) {
    ++$project_updated_count;
    }
    endwhile;

    echo sprintf(
    'Updated %d of %d project(s).',
    $project_updated_count,
    $project_count,
    ) . "\n";

    I created a page and set the template to this template. When I visit the page, it spits out a bunch of var_dump() output, so that I know that each project has a value of NULL for the “architecture” sub-field and a non-zero value for the featured image, as it should be. Then at the end it says “Updated 0 of 115 project(s)”. So something is wrong with the update_field() lines and the projects aren’t getting updated. Thoughts?

  • Solving

    elementor woocommerce products query by custom acf-field

    Hi,
    in WooCommerce I am using the products widget of elementor which allows you to query the products you want to show.

    In the widget/ query I would like to select only products, which have a certain acf-field value, but I cant figure out where to select the acf-field in the query.

    Can anyone help?
    Thank you and kind regards from Germany,
    Carola

  • Unread

    acf local field group issue when saving page

    acf local field group issue when saving page
    Hello everyone !
    I’m currently creating a plugin for a client. To create a plugin as isolated as i can, i decided to generate a custom wordpress page, forced in draft and menu_order -999. In this page, i want to generate ACF fields.

    To generate the page, i’m doing this :


    function GenerateCustomPage(){
    global $option_page_title;
    if (!get_page_by_path(sanitize_title($option_page_title))) { //If page doesn't exist
    $page_args = array(
    'post_title' => $page_title,
    'post_name' => sanitize_title($option_page_title),
    'post_content' => '',
    'post_status' => 'draft',
    'post_type' => 'page',
    'menu_order' => -999,
    'post_author' => 1,
    );
    wp_insert_post($page_args);
    } else { //If the page exist, force draft and menu order
    $page = get_page_by_path(sanitize_title($option_page_title));
    $page->menu_order = -999;
    $page->post_status = 'draft';
    wp_update_post($page);
    }
    }
    add_action('after_setup_theme', 'GenerateCustomPage');

    To generate ACF fields, i’m usint the init hook. Such as :


    function GenerateACFOptions() {
    global $option_page_title;
    if ( ! function_exists( 'acf_add_local_field_group' ) ) {
    return;
    }
    acf_add_local_field_group( array(
    'key' => 'group_floating_bar_options',
    'title' => 'Floating Bar Options',
    'fields' => array(
    array(
    'key' => 'field_floating_bar_item_1',
    'label' => 'Item 1',
    'name' => 'item_1',
    'aria-label' => '',
    'type' => 'group',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'layout' => 'table',
    'sub_fields' => array(
    array(
    'key' => 'field_floating_bar_item_1_display',
    'label' => 'Display',
    'name' => 'item_display',
    'aria-label' => '',
    'type' => 'true_false',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'message' => '',
    'default_value' => 0,
    'ui_on_text' => '',
    'ui_off_text' => '',
    'ui' => 1,
    ),
    array(
    'key' => 'field_floating_bar_item_1_link',
    'label' => 'Lien',
    'name' => 'item_link',
    'aria-label' => '',
    'type' => 'link',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'return_format' => 'array',
    ),
    array(
    'key' => 'field_floating_bar_item_1_image',
    'label' => 'image',
    'name' => 'item_image',
    'aria-label' => '',
    'type' => 'image',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'return_format' => 'array',
    'library' => 'all',
    'min_width' => '',
    'min_height' => '',
    'min_size' => '',
    'max_width' => '',
    'max_height' => '',
    'max_size' => '',
    'mime_types' => 'png, svg',
    'preview_size' => 'medium',
    ),
    ),
    ),array(
    'key' => 'field_floating_bar_item_2',
    'label' => 'Item 2',
    'name' => 'item_2',
    'aria-label' => '',
    'type' => 'group',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'layout' => 'table',
    'sub_fields' => array(
    array(
    'key' => 'field_floating_bar_item_2_display',
    'label' => 'Display',
    'name' => 'item_display',
    'aria-label' => '',
    'type' => 'true_false',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'message' => '',
    'default_value' => 0,
    'ui_on_text' => '',
    'ui_off_text' => '',
    'ui' => 1,
    ),
    array(
    'key' => 'field_floating_bar_item_2_link',
    'label' => 'Lien',
    'name' => 'item_link',
    'aria-label' => '',
    'type' => 'link',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'return_format' => 'array',
    ),
    array(
    'key' => 'field_floating_bar_item_2_image',
    'label' => 'image',
    'name' => 'item_image',
    'aria-label' => '',
    'type' => 'image',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'return_format' => 'array',
    'library' => 'all',
    'min_width' => '',
    'min_height' => '',
    'min_size' => '',
    'max_width' => '',
    'max_height' => '',
    'max_size' => '',
    'mime_types' => 'png, svg',
    'preview_size' => 'medium',
    ),
    ),
    ),
    ),
    'location' => array(
    array(
    array(
    'param' => 'page',
    'operator' => '==',
    'value' => get_page_by_path(sanitize_title($option_page_title))->ID,
    ),
    ),
    ),
    'menu_order' => -1,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    'active' => true,
    'description' => '',
    'show_in_rest' => 0,
    ) );
    }
    add_action( 'acf/init', 'GenerateACFOptions');

    The fields are correctly Shown inside the gutenberg editor with my code. Yet, when i save draft or even publish the page and then refresh my page, everything is cleaned. I have other general fields in my website, created inside the ACF admin page, and they are working perfectly fine. When i try to use the get_fields($id_of_the_option_page);, only the general ACF are shown, not the code generated ones.

    Do you have any idea on the problem ?
    Thanks for your patience, i will provide more info if needed

  • Helping

    Trying to add another tag field in ACF

    Howdy, all. I’m trying to add a field where I can add another location by using tags. So I have the normal field in the admin panel where you enter tags, but then I would like to have a different place to add them in, too.

    Currently, what I have is:

    $location1 = get_field('other_location_1'); ?>
    if(get_field('other_location_1')) {
    
    echo '<a href="' . site_url('/tag/').$location1 . '" style="text-transform: Capitalize;">' . $location1 . ', Arizona</a>';
    }
    else {
    echo "<span class=\"font\">No other location specified</span>";
    }

    This shows up as it should, but it’s not exactly tying itself in to the normal tag structure. I’m not quite sure how to work this but hoping someone out there might?

    Thanks in advance!

  • Unread

    Custom fields as related days and times

    Hi,

    I have a problem that should be simple but that I’m struggling with, so I hope someone could help me:

    I need to build a form for classes on various activities, for which I created a custom post type “Activity”.
    Each activity can take place on any one or more weekdays, in different random timeframes, for example:
    Day Start End
    Monday 8:30 9:00
    Wednesday 12:00 15:00
    Saturday 18:00 19:30

    I can make custom fields for all of these, but to be able to perform relevant searches in the front end, I need them to be related in some way. In other words, the days, start dates and end dates must be related “vertically” to appear in the same search (which would be the case if the days where in a list for example, but not if each field has a different name), while still keeping each day related to its relevant start and date time “horizontally”- which is not possible if I use lists, or any other field type that I can think of.
    If my custom fields are structured properly, I have no problem making the queries that return the correct searches (for instance find all activities that happen at 6pm on saturdays), but if the times and days are unrelated, it will return meaningless results.

    Perhaps I’m an idiot and I’m approaching this from a totally wrong perspective, but that’s where I am at the moment!

    Thanks for any help,
    Roger

  • Solving

    Update_field for multiple Posts using one sql query

    I update around 300 posts a few times a week with a process similar to this:

    $schools = get_schools_object_from_csv($file_path);
    
    foreach ($schools as $id => $school_data) {
      $post_id = get_post_id_by_school_id($id);
      if (empty($post_id)) {
        $post_id = wp_insert_post( [...$school_data[stuffToCreatePost]] );
        update_field('programs', $data['programs'], $post_id);
      } else {
          update_field('programs', $data['programs'], $post_id);
      }
    }

    These schools are sometimes existing schools (a post already exists) where we need to update the school’s programs: an ACF repeater, or it’s a new school where I need to wp_insert_post and then I add the programs to that post.

    This process takes around 1 minute for around 300 schools. I’m wondering if it could be faster.

    I think I could improve the time significantly if I use php to iterate through the schools and create 1 SQL query, similar to what was described in this other topic where they recommend:

    INSERT INTO wp_postmea (post_id, meta_key, meta_value) VALUES ("1", "field_1", "value_1"),("1", "_field_1", "field_0123456789"),..... etc.

    update_field() allows me to dump a whole array/object of the “programs” repeater field into a:
    update_field('programs', $data['programs'], $post_id);

    I’m not sure how to handle this into a sql query.

    But my thought is that I could run 1 query to fetch ALL post IDs for every school (instead of a db query inside the foreach to get just 1 postID), and then save that PostID to the school array.

    Then do a foreach for $schools and build a sql query (psuedo code):

    $sql=[]
    foreach($schools as $id => $school) {
      $sql[] = "INSERT INTO wp_postmeta (post_id, meta_key, meta_value) 
      VALUES ($school[post_id], "meta_key for programs(?)", $school['programs'])
      ON DUPLICATE KEY UPDATE meta_value = $school['programs']"
    }
    
    $sql_query = implode(' ; ', $sql);
    
    $wpdb->query($sql_query)

    This would allow PHP to run quickly to build one large sql query, with just 1 wpdb query to insert OR update all schools/programs.

    At this point I’m just curious if I can update an entire repeater field w/ a sql query this way?

Viewing 25 results - 151 through 175 (of 21,345 total)