Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

topic

  • Helping

    Post Object Causing Issue

    I have an issue where the_permalink isn’t working when post_object is being used.

    <?php the_permalink(); ?> This should be the post link but is, instead, showing the current page URL on the frontend.

    What have I missed?

    Can anyone help?

    Code below;

    
    <?php
                    $args = array(
                        'post_type' => 'cpd',
                        'posts_per_page' => -1,
                        'orderby' => 'title',
                        'order' => 'asc'
                    );
                    $the_query = new WP_Query( $args ); ?>
    
                    <?php if ( $the_query->have_posts() ) : ?>
                    
                    <div id="cpd-items" class="p25top quiz-results">
    
                        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
                        <div class="cpd-item quiz-result p25">
                            
                            <div class="cpd-item-icon">
                            <i class="fa-light fa-file-lines"></i>
                            </div>
                            
                            <div class="cpd-item-content">
                                
                                <h5><?php the_title(); ?></h5>
                                
                                <?php $post_object = get_field('quiz_results'); ?>
    
                                <?php if( $post_object ): ?>
                                <?php $post = $post_object; setup_postdata( $post ); ?> 
                                <?php $postid = get_the_ID(); ?>
                                <?php echo $postid; ?>
                                <?php wp_reset_postdata( $post ) ; ?> 
                                <?php endif; ?>
                        
                                
                                <p class="take-quiz-text">You have not yet taken this quiz. Please click the button below.</p>
                                
                                <p class="p25top retake-quiz-button"><a>">Re-Take the Quiz</a></p>
                                
                                <p class="p25top take-quiz-button"><a>">Take the Quiz</a></p>   
                            
                            </div>
    
                        </div>
    
                        <?php endwhile; ?>
                        
                    </div>
    
                    <?php wp_reset_postdata( $the_query ); ?>
    
                    <?php endif; ?>
    
                    <?php } else { ?>
    
                    <?php } ?>
    
  • Solved

    InnerBlocks Template Pre-populate ACF Repeater

    Hello,

    Can anyone help me with pre-populated ACF repeater in innerblock template?

    
    $template = array(
        array('core/heading', array(
            'level' => 2,
            'placeholder' => 'Schrijf de titel',
        )),
        array('core/paragraph', array(
            'placeholder' => 'Schrijf tekst',
        )),
    
        This is a repeater field with 3 sub_fields -  Link  -  Color  -  Icon
        array('acf/tf-buttons', array(
        )),
    
        Something like this?
        array('acf/tf-buttons', array('data' => array('text_field'=> 'Test!'))),
    );
    
    global $allowed_jsx_blocks;
    echo '<InnerBlocks template="' . esc_attr( wp_json_encode( $template ) ) . '" allowedBlocks="' . esc_attr( wp_json_encode( $allowed_jsx_blocks ) ) . '" />';
    

    I have this problem often and never found a solution to Pre Populate acf repeater fields

    I tried this, but doesn’t fill the repeater field:

    
    This is a simpel repeater field with one text field
    
    array('acf/tf-buttons',
        array('data' =>
            array('test_rep'=>
                array('data' =>
                    array('test_rep_text'=> 'test')
                )
            )
        )
    ),
    
  • Solved

    get_row_layout() not showing all layouts

    I inherited a site using ACF after my predecessor left my company, and I have never worked with WordPress or ACF before now.

    The theme of the site I’m managing has a custom page template called single-everfi-toolkit.php, which is pulling in layouts from a field called “Content Blocks”, which is Flexible Content:

    
    if (have_rows('content_blocks')) {
                                    while (have_rows('content_blocks')) {
                                        the_row();
    
                                        $everfi_fc_layout = get_row_layout();
                                        set_query_var('everfi_fc_layout',$everfi_fc_layout);
                                        set_query_var('everfi_fc_initial_cols', 4);//NOTE: refers to the bootstrap col-#
    
                                        get_template_part('includes/fc', $everfi_fc_layout); ?>
                                        <hr/>
                                    <?php }
                                }

    In the Includes folder of the theme are PHP files for all the existing layouts, with the prefixes “fc-” and then the name of the layout. I Add a Test Text layout to the Field in ACF, then made the corresponding PHP file “fc-test-text.php”:

    <?php
    $title = get_sub_field('block_title');
    $css_id = get_sub_field('css_id');
    $css_class = get_sub_field('css_class');
    ?>
    <section<?php echo($css_id ? ' id="' . $css_id .'"' : ''); ?> class="fc-test-text content-block<?php echo($css_class ? ' ' . $css_class : ''); ?>">
        <?php
        if($title){
            echo '<h3>'.$title.'</h3>';
        }
        ?>
        <?php
        if(get_sub_field('is_intro')){
            the_sub_field('intro_content');
        }
        ?>
        <div class="testTextContainer">
            <p><?php echo esc_html( get_field('text') ); ?></p>
        </div>
    </section>
    

    I can add my Test Text layout in my Content Blocks field when editing a toolkit page, and fill out all the fields as expected. However, the content does not show on the toolkit after saving. I tested existing layouts and they show just fine. Can anyone please help me understand what I need to do to get my Test Text content to show on the page as well?

  • Solved

    Re-using fields in different groups? Can they simply have the same name?

    I have been using Toolset with WordPress and before that I was a Joomla/Seblod user, so I was caught a bit off guard by the fact that ACF doesn’t make fields re-usable (from what I can tell).

    In Toolset, you create a field group, create fields in that group, hit save; and when you create the next field group, you can choose from the fields you have created in all previous field groups, and this can be repeated. J!Seblod is the same from my recollection. The groups seem to be used only for assigning (location)… which post-types/taxonomies/etc are using which fields for the postmeta. When you create a view, all of the saved values of the field that you select by name are filtered and collated the same.

    I can see that in ACF you can’t choose from fields you’ve already created. I suspect there are may be good reasons for this, so you instead have to create new fields in each group. But you can create new fields with the same name… the key will be automatically set for uniqueness, but the name can be the same. Is this basically the same thing?

    Will the fields be filtered and collated the same despite the different field keys, and if so are there any long-term issues to consider when using the same name in multiple field groups?

    If that’s not clear, here’s the case that had me take a step back: creating a product catalog with technical specification fields that can be used for a variety of products, which themselves could belong to one or more product types (taxonomy, we’ll call each category a-to-z for simplicity). We don’t want the user to be confronted with fields that don’t specifically apply to the type of product they are creating, so we need the fields filtered by the product type.

    You may have ‘wattage’ that applies to half of the product types and not to the other half. You may have ‘frequency’ that applies to all but one product type. You may have ‘max dB’ that applies to only one product type. And so forth.

    Trying to achieve this without reusing a single field, so that each product is using the correct field with the same field name and the same field key as other products that share the field is burdensome:

    one field group is assigned to a,b,c,d,e,f,g,h,i,j,k,l product types,
    one field group is assigned to b,g,s,v,z product types,
    one field group is assigned to d,e,g,i,k,m,n product types,
    one field group is assigned to e product type,
    one field group is assigned to q,r,s,t,u,v,w,x,y,z product types,
    one field group is assigned to l,t,r,s product types,
    one field group is assigned to l,t,r product types,
    and so on and so on… not even finished yet.

    This can’t be the right way to do it…

    Most of the product types are overlapping to ensure the fields aren’t used more than once, but this makes it difficult to navigate the field group admin page, and it really makes the post editor a mess with multiple groups to the same product type.

    If it were on Toolset the field groups would be: one for each, a-z, and the fields would be repeated on each, ensuring each product type has only one group (not messy on the post editor screen or the field group admin page).

  • Solved

    Javascript API returning NULL

    I’m enqueuing my script like this.

     // Sitewide.js
      wp_enqueue_script('KPX-JS', get_stylesheet_directory_uri() . '/js/sitewide.js',  array( 'acf-input' ), '', true);
    

    and this the contents of my JS file.

     jQuery( document ).ready( function( $ ) {
        if ( typeof acf !== 'undefined' ) {
            console.log( 'ACF is defined', acf );
        }
    
    });
    
    acf.add_action('load', function() {
        // Your code here
        var postID = acf.get('post_id');
        console.log(postID);
        //
    });
    
    

    in my console log i’m getting null from any field i try to read.

    `ACF is defined {data: {…}, get: ƒ, has: ƒ, set: ƒ, uniqueId: ƒ, …}
    sitewide.js?ver=6.3.1:14 null

    Any ideas where i’m going wrong here?

  • Solved

    Sorting taxonomies not working

    Hello,

    I’m thrilled to use ACF now, I don’t know why I wasn’t using it before!

    Small issue here on this web site: https://www.leshivernales.be/les-danseurs/

    I have created a custom post type called “Danseurs” with simple content. I added a “Année” taxonomy (year) so I could sort out the dancers based on the years when they attended the event.

    The taxonomy terms are in the correct order (2012-2023) and in the taxonomy settings I’ve used the option “Sort the terms”

    But when you go on the output, they are grouped by taxonomy (which is perfect) but the taxonomy terms are absolutely not sorted 🙁

    What am I doing wrong?
    Even worse, it seems to be random and not always the same thing when you refresh the page …

    Below is the code used to display the dancers grouped by years (taxonomy)
    Any help would really be appreciated!

    Thanks,
    Antoine

    <?php 
    					$annees = get_terms( array(
    						'taxonomy' => 'annee',
    						'hide_empty' => true
    						)
    					);
    
    					$order = array();
    					foreach( $annees as $i => $annee ) {
    						$order[ $i ] = $annee->count;
    					}
    					
    					array_multisort( $order, SORT_DESC, $annees );
    					
    					//endforeach;
    					
    					foreach( $annees as $annee ) : 
    					
    					$args = array(
    						'post_type'         => 'danseur',
    						'posts_per_page'    => -1,
    						'orderby' => 'title',
    						'order' => 'ASC',
    						'tax_query' => array(
    							array(
    								'taxonomy' => 'annee',
    								'terms' => $annee->slug,
    								'field' => 'slug',
    								'orderby' => 'menu_order',
    								'order' => 'ASC',
    							),
    						),							    
    					);
    					$danseurs = new WP_Query($args); 
    				?>
    					
    				<div class="row danseur-list mb-5">
    					<h2 class="years h3 col-12"><?php echo $annee->name; ?></h2>
    				
    					<?php foreach( $danseurs->posts as $post ) : setup_postdata( $post ); ?>
    					
    					<div class="box col-6 col-lg-3 col-xl-2 mb-3">
    						<div class="inner">
    							<?php echo the_post_thumbnail( 'large', array('class' => 'img-fluid')); ?>
    							<div class="p-3">
    								<a>" title="<?php the_title(); ?>" class="stretched-link"><?php the_title(); ?></a>
    							</div>
    						</div>
    					</div>
    					
    					<?php endforeach; wp_reset_postdata(); ?>
    				</div>
    					
    				<?php endforeach; ?>
  • Helping

    The output format problem when using Field Type SELECT

    If I use the Field Type SELECT to choose the corresponding options for a post it shows nicely on frontend with Elementor Title element. For example choosing a value “Red” is shown as Red on the frontend.

    I need to do the selection for Elementor Loop Grid query using Advanced Queries plugin. The problem is that it doesn’t output the value as Red but [“Red”] and this doesn’t match in the query because of the special characters.

    Any ideas how to solve this?

  • Helping

    Using ACF Colour Picker To Override CSS

    Hi

    How can I use ACF’s colour picker field to override colours set by the CSS? I’m using Divi. There are multiple pages with the colour picker field, and the chosen colour should only override that page.

    I tried a few different ways, including adding this to function.php

    
    function enqueue_custom_js() {
        // Enqueue the JavaScript file from the child theme's directory
        wp_enqueue_script('branding-colors-js', get_stylesheet_directory_uri() . '/js/branding-colours.js', array('jquery'), '1.0', true);
    
        // Pass ACF field values to the JavaScript
        $acf_data = array(
            'primaryColour' => do_shortcode('[acf_views view-id="247125" name="Primary Colour"]'),
            'secondaryColour' => do_shortcode('[acf_views view-id="246841" name="Property Map"]')
        );
        wp_localize_script('branding-colors-js', 'acfData', $acf_data);
    }
    add_action('wp_enqueue_scripts', 'enqueue_custom_js');

    and this is the js

    jQuery(document).ready(function ($) {
        // Function to replace colors
        function replaceColor(oldColor, newColor) {
            $("*").each(function (index, element) {
                var currentColor = $(element).css('color');
                if (currentColor === oldColor) {
                    $(element).css('color', newColor);
                }
                var currentBgColor = $(element).css('background-color');
                if (currentBgColor === oldColor) {
                    $(element).css('background-color', newColor);
                }
            });
        }
    
        // Check if ACF data is available
        if (typeof acfData !== 'undefined') {
            // Replace primary color
            if (acfData.primaryColour) {
                replaceColor('#0b5f6a', acfData.primaryColour);
            }
    
            // Replace secondary color
            if (acfData.secondaryColour) {
                replaceColor('#CBE4E8', acfData.secondaryColour);
            }
        }
    });
    
    

    I also tried not using ACF View shortcodes but nothing works.

    function enqueue_custom_js() {
        // Enqueue the JavaScript file from the child theme's directory
        wp_enqueue_script('branding-colors-js', get_stylesheet_directory_uri() . '/js/branding-colours.js', array('jquery'), '1.0', true);
    
        // Pass ACF field values to the JavaScript
        $acf_data = array(
            'primaryColour' => get_field('primary_colour', get_the_ID()),
            'secondaryColour' => get_field('secondary_colour', get_the_ID())
        );
        wp_localize_script('branding-colors-js', 'acfData', $acf_data);
    }
    add_action('wp_enqueue_scripts', 'enqueue_custom_js');
    

    The ACF field name’s are primary_colour and secondary_colour

  • Solving

    ACF field for JSON code (using elementor widget)

    Do anyone knows if it is possible to insert JSON-LD code (such as below) into an ACF field that is connected to a elementor widget (eg. a HTML elementor widget with the ACF field as input)? At the moment, when I insert JSON-LD code, the front-end removes the <script> tag somehow :O Even though i insert the code below into the ACF field.

    <script type=”application/ld+json”>
    {
    “@context”: “https://schema.org&#8221;,
    “@type”: “FAQPage”,
    “mainEntity”: [

    {
    “@type”: “Question”,
    “name”: “Hvad er kernemælk?”,
    “acceptedAnswer”: {
    “@type”: “Answer”,
    “text”: “Kernemælk er en lavfedtig mælkevariant, der er blevet syrnet ved tilsætning af mælkesyrebakterier. Den har en let og syrlig smag og kan bruges i mange forskellige madlavning og bagning opskrifter.”
    }
    }
    ,
    {
    “@type”: “Question”,
    “name”: “Hvad er forskellen på kernemælk og kærnemælk?”,
    “acceptedAnswer”: {
    “@type”: “Answer”,
    “text”: “Kernemælk og kærnemælk er faktisk det samme produkt. De to navne bruges ofte om hinanden i Danmark.”
    }
    }
    ,
    {
    “@type”: “Question”,
    “name”: “Hvad kan jeg bruge kernemælk til?”,
    “acceptedAnswer”: {
    “@type”: “Answer”,
    “text”: “Kernemælk kan bruges som ingrediens i bagværk som brød og kager for at gøre dem mere luftige og saftige. Den kan også bruges til at lave marinader, dressinger og smoothies, eller bare drikkes rent som en forfriskende drik.”
    }
    }

    ]
    }
    </script>

  • Solving

    How to reduce the number of requests ?

    Hello,

    I have a problem, do you have a solution to reduce the number of requests coming from acf_register_block_type() ? Because the more blocks we create, the more the number of requests increases, even if I do my utmost to optimize the calls to CSS and JS files within. ACF significantly increases the TTFB and therefore it impacts the performance of a site. Do you have a solution?

    Thank you,
    Jeffrey

  • Solved

    get_field always returns null even with content and page id set

    I’m using ACF Version 6.2.1

    I have this in a template partial, called in my front page template (outside of the loop):
    <?php var_dump(get_field('bannertabbed')); ?>

    I have added dummy content to the field group on my front page. When I output get_post_meta() I can see that all my fields are there with the dummy content. I have also tried adding my ID to the get_field call but it’s still returning as NULL. I have another field group on the same page, which is also outside of the loop and it’s returning everything fine. Why is this one not? This is the export of the field group:

    
    add_action( 'acf/include_fields', function() {
    	if ( ! function_exists( 'acf_add_local_field_group' ) ) {
    		return;
    	}
    
    	acf_add_local_field_group( array(
    	'key' => 'group_65133e0381c44',
    	'title' => 'bannertabbed',
    	'fields' => array(
    		array(
    			'key' => 'field_65133e0545d2d',
    			'label' => 'banner1',
    			'name' => '',
    			'aria-label' => '',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array(
    			'key' => 'field_65133e5345d2e',
    			'label' => 'image1',
    			'name' => 'image1',
    			'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' => '',
    			'preview_size' => 'medium',
    		),
    		array(
    			'key' => 'field_65133e6445d2f',
    			'label' => 'title1',
    			'name' => 'title1',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    		array(
    			'key' => 'field_65133e6d45d30',
    			'label' => 'text1',
    			'name' => 'text1',
    			'aria-label' => '',
    			'type' => 'textarea',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'rows' => '',
    			'placeholder' => '',
    			'new_lines' => '',
    		),
    		array(
    			'key' => 'field_65133e8245d31',
    			'label' => 'link1',
    			'name' => 'link1',
    			'aria-label' => '',
    			'type' => 'link',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'url',
    		),
    		array(
    			'key' => 'field_65133ed645d32',
    			'label' => 'tabtext1',
    			'name' => 'tabtext1',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    		array(
    			'key' => 'field_651340a9b2b50',
    			'label' => 'banner2',
    			'name' => '',
    			'aria-label' => '',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array(
    			'key' => 'field_651340edb2b52',
    			'label' => 'image2',
    			'name' => 'image2',
    			'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' => '',
    			'preview_size' => 'medium',
    		),
    		array(
    			'key' => 'field_6513413ab2b54',
    			'label' => 'title2',
    			'name' => 'title2',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    		array(
    			'key' => 'field_65134190b2b56',
    			'label' => 'text2',
    			'name' => 'text2',
    			'aria-label' => '',
    			'type' => 'textarea',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'rows' => '',
    			'placeholder' => '',
    			'new_lines' => '',
    		),
    		array(
    			'key' => 'field_651341cfb2b59',
    			'label' => 'link2',
    			'name' => 'link2',
    			'aria-label' => '',
    			'type' => 'link',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'url',
    		),
    		array(
    			'key' => 'field_65134240e4fab',
    			'label' => 'tabtext2',
    			'name' => 'tabtext2',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    		array(
    			'key' => 'field_651340dbb2b51',
    			'label' => 'banner3',
    			'name' => '',
    			'aria-label' => '',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array(
    			'key' => 'field_651340ffb2b53',
    			'label' => 'image3',
    			'name' => 'image3',
    			'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' => '',
    			'preview_size' => 'medium',
    		),
    		array(
    			'key' => 'field_65134146b2b55',
    			'label' => 'title3',
    			'name' => 'title3',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    		array(
    			'key' => 'field_65134195b2b57',
    			'label' => 'text3',
    			'name' => 'text3',
    			'aria-label' => '',
    			'type' => 'textarea',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'rows' => '',
    			'placeholder' => '',
    			'new_lines' => '',
    		),
    		array(
    			'key' => 'field_651341cdb2b58',
    			'label' => 'link3',
    			'name' => 'link3',
    			'aria-label' => '',
    			'type' => 'link',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'url',
    		),
    		array(
    			'key' => 'field_65134243e4fac',
    			'label' => 'tabtext3',
    			'name' => 'tabtext3',
    			'aria-label' => '',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'maxlength' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'page_type',
    				'operator' => '==',
    				'value' => 'front_page',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => true,
    	'description' => '',
    	'show_in_rest' => 0,
    ) );
    } );
    
    

    I don’t know what else to check. It looks correct. It’s driving me crazy.

  • Helping

    Different (ID)

    Hi,

    I am encountering an issue while configuring my WordPress site using Advanced Custom Fields (ACF) and Elementor. My goal is to properly link the custom field “training dates” to the custom field “trainings.” I am using ACF to manage custom fields and Elementor to design my training pages.

    The main problem I am facing is as follows:
    The “training dates” field group contains a different (ID) for each date, a unique reference that corresponds to the “trainings” custom field, and the start and end dates. I want to display all the training dates on my training pages, indicating the start and end date for each training.

    Despite my efforts, I am unable to ensure that the dates correctly match the corresponding trainings.

  • Solving

    ACF version downgrades to 5.9.5 after migration!

    I’m using ACF Pro, and when I’ve migrated my site from a staging environment on a subdomain to the live site, the ACF plugin reverts from the latest version (6.2.1.1) to 5.9.5.

    No matter how much I update it within the plugin list, the plugin itself or even manually updating it by uploading the zip file with the new version the old one persists.

    With updating it keeps asking me to update to the newest version on the plugin list, but it says it’s been updated, but in ACF it states that it is using 5.9.5. I’m at a loss of what to do. I’ve used Duplicator Pro to do the migration and nothing seems to work.

    I’ve been in contact with customer support, but I have yet to gain a solution to this issue. It’s for a client and I have made many custom fields and a CPT with it’s own taxonomies and all that disappears after migration to the live site. I’ve migrated to a fresh install on a new subdomain and there have been no issues thus far.

    Do you think it’s because I’m migrating from MySQL (subdomain) to MariaDB (live site)? I have not encountered this issue before and I don’t know what else to try. I looked into the DB and posts seem to be there too, but again the plugin reverts so none of my fields or the CPT menu shows on the sidebar in the dashboard either.

    Would I have to just delete the entire contents of public_html to do a hard reset install WP and do the migration from there? I don’t know what I would even need to delete in the DB to remove whatever is causing this issue.

    Please advise, I’m fairly new with this plugin and am not backend savvy so I’d prefer to not go directly into the php files if I can help it. Any insight into this issue would be greatly appreciated!!

  • Solved

    get_field() in custom taxonomy

    Hello,

    I have some trouble to display fields on a custom taxonomy page, get_field() does not retrieve anything.

    For simple text fields I can use get_term_meta() instead and it works, but I have two others fields that are other taxonomy links that I need to display that can’t work with get_term_meta().

    Here is the code :

    <?php echo get_field( get_queried_object_id(), 'sports' ); ?>

    Did I forgot anything ?

  • Unread

    Best practises to get (modified) custom field data in Gutenberg?

    In some cases, you can not use Gutenberg’s native Dynamic data fields or ACF’s own shortcode. Ie. if you have to format/manipulate the data before displaying it.

    I am finding that there are many ways to get ACF data in Gutenberg. What are the pros and cons of these techniques? What is the recommended way?

    1. Custom shortcode: create a shortcode for ACF data and use it with a Shortcode block. Seems to have some problems with the Query block.
    2. Filter / render_block: Give Gutenberg block a custom class and switch it to ACF content with filter. This works with the Query loop.
    3. Custom hook: Create a custom hook inside the Gutenberg block (requires a plugin/custom code).
    4. Some other, smarter way.

    Thank you for any input or links to more info. I am a bit confused about what to use.

  • Solving

    Loss of Repeater Field Data when Rearranging Layouts in Flexible Content

    Hello,

    When using a Flexible Content field in ACF, which contains layouts that include Repeater fields, there is an issue where changing the order of the layouts in the WordPress admin interface results in the loss of data from the Repeater field within those layouts.

    Environment:

    1. Web Server: Apache/2.4.54 (Unix) OpenSSL/1.0.2u PHP/8.2.0
    2. PHP Version: 8.2.0
    3. max_input_vars 10000
    4. MySQL Server Version: 5.7.39
    5. WordPress Version: 6.3.1
    6. ACF Version: 6.2.1.1

    Statement:

    I wanted to provide an update regarding the configuration change I made in PHP. As recommended in the discussion thread found here: Thread Link, I adjusted the max_input_vars to 10000.

    Unfortunately, despite making this adjustment, the issue of data loss when updating Flexible Content fields persists. The rows continue to disappear in the backend as mentioned in the thread.

    Steps to Reproduce the Issue:

    Create a Flexible Content field in ACF and add layouts that contain Repeater fields.
    Populate data in the Repeater fields within the layouts.
    In the WordPress admin interface, rearrange the order of the layouts within the Flexible Content field.
    Save the changes.
    Notice that the data in the Repeater fields has been erased.

    Additional Information:

    This issue leads to the loss of critical user data and can have a significant impact on their use of ACF.
    Expectations: We expect that rearranging the layouts within the Flexible Content field should not result in data loss within the Repeater fields.

    Thank you for considering this bug report and working towards its resolution. If additional information is required, please feel free to request it.

  • Helping

    ACF Meta Query with fields available based on conditional logic.

    Hello

    I have a custom post type that can be different types:

    • Event
    • Offer
    • Competition
    • News

    The type of the post is defined by an ACF Radio Button field.

    With conditional logic depending on the type selected different ACF fields are showing to fill in per type.

    The event posts have a start_date and an end_date Date fields. All the other types have just some text fields.

    I have a grid listing page where it shows all the posts. I want to filter out the events that their start_date or their end_date was earlier than today but at the same time include all the other types which don’t have the end_date or start_date fields.

    I’ve tried the below:

    
     $query_args = array(
        'post_status' => 'publish',
        'orderby' => array('title' => 'ASC'),
        'paged'    => (get_query_var('paged')) ? get_query_var('paged') : 1,
        'post_type' => 'custom_post', 
        'orderby' => 'date_added', 
        'order' => 'desc', 
        'posts_per_page' => '9',
            'meta_query' => array(
                'relation' => 'OR',
                array(
                    'key' => 'start_date',
                    'compare' => 'NOT EXISTS',
                ),
                array(
                    'key' => 'start_date',
                    'compare' => '>',
                    'value' => date("Y-m-d"),
                    'type' => 'DATE'
                ),
                array(
                    'key' => 'end_date',
                    'compare' => '>',
                    'value' => date("Y-m-d"),
                    'type' => 'DATE'
                )
            )
    );
    

    but this returns nothing.

    Any ideas?

  • Solving

    Efficient CSS in the front end with a modular workflow

    My site has a structure essentially

    blocks
    — my-first-block
    — block.json
    — style.scss
    — style.css
    — template.php
    — my-second-block
    — block.json
    — style.scss
    — style.css
    — template.php

    which is a very good way to product templating blocks for a website and, in the backend, I don’t mind that there’s a CSS file for each block

    but in the front end, I now have a CSS file for every individual block.

    So, the thing I would like to do is keep this way of working in the backend (maybe) but have a single file of all CSS

    THere is a long winded way, that in my style.scss I have many import statements

    import ‘blocks/my-first-block/style.scss’;
    import ‘blocks/my-second-block/style.scss’;

    In a theme that has 40 blocks this is a bit clunky.

    In my block.json the statement that controls the CSS is

    "style": [ "banner-generic" ],

    …which appears to refer to style.css in the folder /blocks/banner-generic. BUt as I’m only learning I’m not entirely sure how this work.

    Any ideas or links to resources?

    I got the initial method from
    https://www.billerickson.net/building-acf-blocks-with-block-json/
    but that only goes so far.

  • Solved

    Using Elementor with Options Pages

    With the advent of the new Options Pages, my first thought was that I could store website-related information that I frequently reuse throughout a site that could be changed in a central location. For examples, the address and phone number of the company for whom the website is being built.
    With that in mind, I created an Options Page and then connected it to a field group consisting of some address fields, similar to what I’d do were I connecting a field group to a page or post. I then filled in those fields via the new option that had then appeared on the left-hand WP menu.
    On a page made with Elementor, I then added a text field and attempted to link it to the ACF field. ACF came up in the list of possible fields, but the ‘key’ field is empty. In other words, there’s no connection of these ACF fields to Elementor.
    Perhaps because this Options Pages feature is new, Elementor has no way to handle this yet.
    If there’s a way to do this without necessarily using Options Pages, could someone direct me to instructions of how I’d go about it?
    Thanks in advance for the help.

  • Solved

    Problem with search title in PostObject

    I have a problem when I want to enable searching by title or ‘content_shop_api_key’; I simply can’t search by title. When I disable that search of title, the code works without any issues. The ACF field ‘postObject’ is located in the User section. Please, if can someone give me some advice. This is my code:

    function custom_acf_post_object_query( $args, $field, $post_id ) {
        // Get the search text
        $the_search = $args['s'];
    
        // Remove it so ACF won't search the posts based on title
        unset($args['s']);
    
        // Search based on custom fields only
        $meta_query_args = array(
            'relation' => 'AND', 
            array(
                'relation' => 'OR', 
                array(
                    'key'     => 'post_title', 
                    'value'   => $the_search,
                    'compare' => 'LIKE'
                ),
                array(
                    'key'     => 'free_content_check',
                    'compare' => 'LIKE',
                    'value'   => $the_search,
                )
            ),
            array(
                'key'     => 'content_shop_api_key',
                'value'   => $the_search,
                'compare' => 'LIKE'
            )
        );
    
        $args['meta_query'] = $meta_query_args;
    
        return $args;
    }
    
    add_filter('acf/fields/post_object/query/name=assign_user_product', 'custom_acf_post_object_query', 10, 3);
  • Unread

    Add identifier for Side Bar

    Hi I have a few ACF blocks which can be used on their own, or inside Repeaters and/or Flexible content.

    I am trying to hide/show a few fields depending on whether the block is on its own or wrapped in a Repeater/Flexible.

    I know conditional logic can be used as it is not parent aware The Blocks in question do have a useContext, so i can identify when it is wrapped or not.

    Im trying to find a Javascript hook/event, which is triggered when you click a Block in the backoffice editor, so i can simply add an additional class to the side bar menu, so my CSS can target the necessary fields … Any ideas are greatly appreciated.

    Thanks

  • Solved

    Strange Behavior with field data and get_field

    I have written an api that is to return back a bunch of ski resort data.

    Here is the function:

    function fs_ski_resorts_data(){
        $args = array(
            'posts_per_page'    => 999,
            'post_type'         => 'fs_ski_resorts',
        );
        $the_query = new WP_Query( $args );
        $fs_ski_resorts = get_posts($args);
        $fs_ski_resorts_data = [];
        $i = 0;
        while( $the_query->have_posts() ) : $the_query->the_post();
              // i have removed all but 1 field to minimize example
              $variable = get_field('fs_ski_resort_data_fs_aa_zoom');
              $fs_ski_resorts_data[$i]['ZOOM']  = $variable ;
              $i++;
        endwhile;
        return $fs_ski_resorts_data;
    }
    

    the fs_ski_resort_data_fs_aa_zoom field is a number. I have 265 records and all of them have a number, 15, however, some return $fs_ski_resorts_data[$i][‘ZOOM’] as NULL and some with 15, as expected. When I enter the view the record for the null ones, I can see 15 is there.

    I have found that if I go to the record with null value from the above function and click UPDATE and then go back and run the above function, the number is there. It is like the number is there but isn’t at the same time. Just wondering what could possibly be the problem.

  • Helping

    repeater field data input

    I’m not very familiar with ACF. Trying to fix a problem with a site.
    Per the documentation on repeater fields,
    https://www.advancedcustomfields.com/resources/how-to-use-the-repeater-field/
    I can see the field appears to be properly created. But in the documentation section “Editing and Inputting Data”, they show an input screen with no description of where to find it or create it or anything. I’ve looked everywhere and can’t find it. Some entries work correctly, one is broken, so I know it’s there somewhere.
    So I THINK my question is simply: how do I access that screen (in the example, it’s the input screen for Menu Category). Thx!

  • Helping

    Custom Post Type and native WP taxonomy

    Hi newbe here. I have a simple question, unfortunately I couldn’t find the answer anywhere. I’m testing the free version of ACF and I have a problem with WP taxonomy (tags). The tag does not list the archive of content created in ACF. Taxonomies created in ACF work flawlessly.

  • Solved

    add_filter “acf/validate_save_post” and acf_add_validation_error

    Sup guys!

    I need some explications please! I’m trying to understand how I can display a custom error message from custom validation and highlight specific fields that have this error.

    I use acf_form for display my form and I have this code for the validation:
    https://pastebin.com/f4qnmnbB

    In this code, I’m sure the variables $email and $confirmEmail work’s good. I’m sure too that the “acf_add_validation_error” function “work” because if it not there, the form pass.

    I have try this too
    acf_add_validation_error('field_65067bde5086e', 'ok')

    I can’t determine why, the “ok” message’s not displayed and the specific field don’t highlight.

    Is there something I don’t understand?

    Could you help me understand better please hehe?

    Thanks guys!

Viewing 25 results - 426 through 450 (of 21,345 total)