I added ACF custom fields to WooCommerce products and assigned them according to their taxonomy terms (product_cat).
Everything was working fine, but when I changed the slug of some terms the location rules disappeared. And when I wanted to reassign them these terms were no longer in the location rules dropdown.
These terms are still present because they are selectable in another ACF rule (see image).
Each time I modify the slug of a term, it disappears from the Taxonomy list of the ACF rules.
I guess I’m not the only one to have encountered this problem, but I haven’t found anything in my research. Is it an ACF bug or a problem on my side?
Thanks,
Laurent Leruste
Is it possible to order the taxonomy terms alphabetically with the admin. I have an ACF Taxonomy field with checkboxes, but it’s outputting them in the order the terms were created and not alphabetically. How would I go about changing that? Here’s a screenshot for reference: http://b3.ms/Oq5nRlBQe90w
I have a custom post type (Colour Swatches) The post type allows you to add a colour and allocate it a category in a repeater. I am listing the post types on a page along with the colours that match a specific category.
Listing the correct colours or each post type is working, this uses a for each loop querying the category sub field. However if no colours match the query the title still appears. I would like the page not to be listed at all if any of the sub fields do not match the category.
I assume the best way to achieve this is through a meta query, but I am not sure where to start with this.
The code below is as far as I’ve got..
<?php
$args = array(
'post_type' => 'colourswatch',
'order' => 'ASC',
'meta_query' => array(
array(
// no idea
)
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
?>
<div class="container container--narrow swatches">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="swatches__material">
<?php if( have_rows( 'colour_swatch' ) ): ?>
// I need to hide this if the category does feature for any colours
<h3 class="swatches__title"><?php the_title(); ?></h3>
<ul class="swatches__colours">
<?php while ( have_rows( 'colour_swatch' ) ) : the_row();
$terms = get_sub_field( 'availability' );
foreach( $terms as $term ) {
if ( $term->name == 'windows' ) : ?>
<li class="swatches__swatch">
<div class="swatches__colour" style="background:<?php the_sub_field( 'colour' ); ?>"></div>
<h4 class="swatches__name"><?php the_sub_field( 'colour_name' ); ?></h4>
</li>
<?php endif; ?>
<?php } ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; wp_reset_query(); ?>
Hello,
I’m not 100% sure but it looks like a bug to me.
I have a CPT called “Event”. With CPT UI, i created a custom taxonomy called “Event type”. This “Event type” taxonomy is only used in the Event post type.
After few months, i need to add an image field to this taxonomy. I tried 2 ways to do this but nothing worked. See my screenshots and you will understand.
How should i do what i want to do? Please tell me.
Thanks for your help,
Josy
———————————–
I run ACF Pro v5.9 + CPT UI 1.7.4.
This code working with image and title but post_per_page doesn’t work and trying 'number' =>1
is work but if any taxonomy Less than one Or equal to one Info will not be showing.
<?php
$tax = 'studio';
$types = get_terms( array(
'post_per_page' => 1,
)
);
foreach($types as $type) { ?>
<?php
$term_link = get_term_link( $type );
$image = get_field('studio_avatar', 'studio_' . $type->term_id . '' );
if ( has_term( $type->term_id, 'studio')) {
echo '<a class="author author-avt inline" href="' . esc_url( $term_link ) . '">';
echo '<img class="si-user" src="' . $image['url'] . '" /> ';
echo '<span>'. $type->name . '</span>';
echo '</a>';
echo '<span class="posted-on inline">';
echo '<i class="si-clock"></i><time>'. $post_date = get_the_date("j F Y") .'</time>';
echo '</span>';
}
?>
<?php } ?>
I’m trying to use this code from documentation and tweak it a bit.
but in taxonomy-studio.php not showing.
I’m trying inspect in chorme code not showing.
<?php
$link = get_field('website');
if( $link ):
$link_url = $link['url'];
?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" >
<span>
<i class="si-globe">website</i>
</span>
</a>
<?php endif; ?>
Hi !
Is it possible to use get_field()
inside acf/fields/taxonomy/query/
filter ?
I try to get the value from an other field from the filter function but it’s seems that what is return is null. The get_filed() function works well outside of this filter. Also how can i debug my variable inside the acf/fields/taxonomy/query/
filter ? When i use var_dump or echo inside the filter, it prevent the filter function from working.
function custom_acf_taxonomy_filter( $args, $field, $post_id ){
$parent = get_field('field_5f326eac0b9d8', false);
$args['parent'] = $parent->term_id;
return $args;
}
add_filter('acf/fields/taxonomy/query/key=field_5f32a57681da9', 'custom_acf_taxonomy_filter',11,3);
Thanks a lot for your help
Hello,
I’ve got a taxonomy setup for posts that I use to create relations for archive pages and I’ve now connect these with pages through ACF taxonomy field. I’m trying to setup a custom filter for Elementor that will list the archive pages on my page.
I’ve gotten the suggestion to use the acf/fields/taxonomy/query filter but I can’t figure out how to: https://www.advancedcustomfields.com/resources/acf-fields-taxonomy-query/
I’ve got a working code that list child pages in Elementor which seems easy enough:
// Showing children of current page in Posts Widget
add_action( ‘elementor_pro/posts/query/my_custom_filter’, function( $query ) {
// Get current post tags
$current_page = get_queried_object_id();
// Modify the query
$query->set( ‘post_parent’, $current_page );
} );
I’ve tried adapt the code but I don’t seem to have enough knowledge to find a way forward. Can anybody help me figure out how to make a similar code for listing archive pages as described above? Would be really grateful for any help or suggestion.