Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

topic

  • Solving

    ACF Taxonomy

    Hey.

    Im trying to create a loop-item for my custom Taxonomy “product_categories” i’ve assigned 2 fields to it, name => “c_name”, image => “c_image”.

    Now when I im in my loop template, i’ve assigned those fields to the text and image but its not showing me anything. I’ve tried searching internet but haven’t got lucky. so posting here in the end.. im using ACF PRO.

    Do reply to my thread.

    Thank You.

  • Solved

    Taxonomy to Find Category Selected

    Hi,

    I’m attempting to create a query to find any Case Studies (a Custom Post Type) that are selected via the page. This is my first time using the Taxonomy field, and although it works, I get the error in Debug mode “Warning: Invalid argument supplied for foreach() in…”. I’ve followed a few suggestions to fix that, but they don’t show any results.

    My Field Page

    
    <img src="https://postimg.cc/D4GNVRYQ" alt="" />
    

    My Code

    
    <?php
      foreach($case_study_category as $cs) { $cs = get_category($cs); }
      $args = array(
        'post_type' => 'case-study',
        'posts_per_page' => 9,
        'post_status' => 'publish',
        'orderby' => 'publish_date',
        'category__in' => array($case_study_category),
      );
    
      $study_query = new WP_Query( $args);
    
      if ( $study_query->have_posts() ) { 
    ?>
      <div class="post-grid post-grid--scroll-mob">
    <?php
      while ( $study_query->have_posts() ) {
        $study_query->the_post();
    
        $name_title = get_field('name_title');
    ?>
      <a>" class="post-block f-rounded-bottom-lg mob-center-fix">
      
      <?php if(has_post_thumbnail()) {
        the_post_thumbnail('case-study', array('class' => 'post-image post-image--featured', 'alt' => $name_title));
       } else {
      ?>
        <img src="https://placehold.co/1232x924" />
      <?php } ?>
        <span class="post-block__text box-pad-xs d-block">
          <h5 class="font-inter color-black weight-600 text-scale-sm mb-0"><?php echo the_title(); ?></h5>
          <?php if( ($name_title) ) : ?><h6 class="post-sub-title font-quicksand color-blue text-uppercase weight-600 mb-0 text-scale-mini"><?php echo $name_title; ?></h6>
        </span><?php endif; ?>
      </a>
    <?php
      }
    ?>
      </div>
    <?php
        wp_reset_postdata();
      } else {
    ?>
      <p class="color-brown">There are currently no Case Studies to show associated with this service.</p>
    <?php
      }
    ?>
    
  • Solving

    Problem with changing CPT post type key

    Hi guys!
    Can you tell me what is the correct way to change CPT “post type/taxonomy key? Iam testing stuff out, I did the following and I see some strange behavior.
    I created my CPT lets say “dog” with ACF6.23 dint use the advanced settings,
    next I added some dummy posts inside my new cpt.
    I went back to the “dog” CPT settings and changed the “post type key” from “dog” to “dog-something”
    When I did that all the dummy posts inside my admin Dog Cpt dissapeared.
    I tried resaving permalinks – didnt help. When I changed “post type key” back to “dog” they all reappeared on the post list.
    It looks like these post are still somewhere in the database only hidden for some reason?.
    Iam curious to why this is happening or what did I do wrong?
    Thank you for you help!

  • Solving

    Taxonomy field fails loading categories in backend

    I’ve created an ACF taxonomy field that should show my categories inside my custom taxonomy. This taxonomy contains categories and has connected posts. Normally the field should show all the categories, but now it wont. Instead it first loads and after that it gives the error ‘Laden mislukt’ which is dutch for something like ‘Loading Failed’. Does someone know what could be the reason the field won’t load anymore? Beside a font issue we dont have specific errors in the console or php-errors when activating the debug.

    Code for registering the custom post type and taxonomy

    
    
            function cpt_kennisartikel() {
                $labels = array(
                    'name'               => _x( 'Kennisartikelen', 'i2sa'),
                    'singular_name'      => _x( 'Kennisartikel', 'i2sa'),
                    'menu_name'          => _x( 'Kennisartikelen', 'i2sa'),
                    'name_admin_bar'     => _x( 'Kennisartikelen', 'i2sa'),
                    'add_new'            => _x( 'New item', 'i2sa'),
                    'add_new_item'       => __( 'Add new item', 'i2sa'),
                    'new_item'           => __( 'New item', 'i2sa'),
                    'edit_item'          => __( 'Edit item', 'i2sa'),
                    'view_item'          => __( 'View item', 'i2sa'),
                    'all_items'          => __( "All items", 'i2sa'),
                    'search_items'       => __( 'Search item', 'i2sa'),
                    'parent_item_colon'  => __( 'Parent item:', 'i2sa'),
                    'not_found'          => __( 'Search query not found.', 'i2sa'),
                    'not_found_in_trash' => __( 'Search query not found.', 'i2sa')
                );
            
                $args = array(
                    'labels'             => $labels,
                    'description'        => "Beschrijving i2sa",
                    'public'             => true, //openbaar
                    'exclude_from_search'=> false, //uitschakelen voor zoekopdrachten
                    'publicly_queryable' => true, //publiekelijk vindbaar
                    'show_in_nav_menus'  => false, //toon in navigatie
                    'menu_icon'          => 'dashicons-lightbulb',
                    'show_ui'            => true,
                    'show_in_menu'       => true,
                    'show_in_rest'       => true,
                    'query_var'          => true,
                    'rewrite'            => array( 'slug' => 'kb' ), //custom url
                    'capability_type'    => 'post',
                    'has_archive'        => false, //heeft archivepage
                    'hierarchical'       => false, // true maakt het een pagina
                    'menu_position'      => 5, //null = geen
                    'supports'           => array('editor', 'title', 'thumbnail'), //gesupporte functionaliteiten
                );
                register_post_type( 'kennisartikel', $args );
        
                //flush_rewrite_rules();
            }
            add_action( 'init', 'cpt_kennisartikel' );
        
        
            function cstm_taxonomy_kb() {
                $post_types = array('kennisartikel');
            
                $taxonomy_args = array(
                    'label' => 'Artikel Categorie (KB)',
                    'rewrite' => array('slug' => 'tax-kb'),
                    'hierarchical' => true,
                    'public' => true,
                    'show_ui' => true,
                    'show_in_rest'       => true,
                    'show_admin_column' => true,
                    'has_archive' => false,
                );
            
                foreach ($post_types as $post_type) {
                    register_taxonomy('cc_tax_kb', $post_type, $taxonomy_args);
                }
            }
            
            add_action('init', 'cstm_taxonomy_kb');
    
    

    Setup of the field and error attached as screenshot.

  • Unread

    Dropdown list to choose which taxonomy key to use for Elementor Pro dynamic img

    Hi, I need to do dynamic field in Elementor Pro so that Image widget will get featured image from specific taxonomy for Woo product.

    This is the scenario:
    I have Product 1 that is in Taxonomy 1, Taxonomy 2 and Taxonomy 3.
    All taxonomies have its own featured image defined in ACF.
    https://prnt.sc/SX04RemZu3Ap

    So I want to place Image container and choose Dynamic field as source for the image and when I choose key I want to be able to choose specific taxonomy for that place.
    https://prnt.sc/Slz1419_3j_-

    How can I achieve this?
    https://prnt.sc/iVIAd0vyd3Er

    Currently when I choose Featured Image Taxonomy I dont get anything which is reasonable because it gets the url from all taxonomies that this product is member of.

    Thanks!

  • Helping

    Taxonomy RSS Feed

    I am trying to pull an RSS feed into a newsletter using a custom post type and taxonomy. I’ve tried the following URL but it doesn’t seem to work.

    custom post type = news
    taxonomy = newsletter
    the selected taxonomy = featured

    https://www.theave.biz/news/newsletter/featured/feed

    I also tried: https://www.theave.biz/news/category/featured/feed which I don’t think is correct.

    When I use https://www.theave.biz/news/feed it works but it pulls all the posts in.

    Any help would be greatly appreciated.

  • Solving

    Featured image for custom taxonomy

    Hello !

    I’ve created a custom taxonomy and created a custom image field for.
    I would use it as a featured image (for a gridbuiler).
    Any idea how to do it ?

    Thanks !

  • Solving

    Get all repeater fields outside the loop, but grouped?

    I was hoping someone could point me in a direction, as my searches are bringing up things that are not applicable. My posts keep getting marked as sp@m, so excuse my clumsy censoring. I’m not sure what’s tripping it up.

    I have a CPT, “B00ks”. Within that, there is a repeater field for “Editions”. Within that, there is a select dropdown to choose a “Type”, as well as an image field for the “Cover”, and a nested repeater for links to buy them. The structure looks like below:

    B00ks
    ---Editions (Repeater)
    ------Type (Select/Taxonomy)
    ------Cover (Image)
    ------Purchase Links (Repeater)
    -----------Link Name (Text)
    -----------URL (URL)

    I’ve gotten all this to show up on the single-b00ks page in a super spiffy way, and I’m jazzed! I’m now looking to build an “Editions” page which should show all editions of all b00ks, grouped by “Type”. This way, all audiob00ks will appear in a row, and then all paperbacks, and then all hardbacks, so and so forth.

    Since this will be on its own page, it’ll be outside of the CPT loop. I’m not quite sure where to start with both querying the posts, plucking out ONLY the special editions, and then grouping them by tax (if applicable, as some don’t have a “Type”).

    If anyone could point me in a direction, I’d really appreciate it!

  • Solving

    Assigning Custom Fields To Child/Parents?

    Hi,

    Regarding this topic :

    https://support.advancedcustomfields.com/forums/topic/assigning-custom-fields-to-childparents/

    It would be nice to have the same option as “page type” for taxonomies ( taxonomy type )

    has child, or has parent.

  • Helping

    How to display lists of posts by taxonomy slug, indicated in ACF?

    I want to display lists of posts from taxonomy on page where I indicated that taxonomy in ACF field.

    For example, I have pages “Baseball” and “Soccer” that use my custom template. I want to display there lists of posts that have terms “baseball-news” and “soccer-news” from standard tag taxonomy. I can indicate the slug of taxonomy in ACF custom field, so how, having this slug, I can use it to create a list of posts?

  • Solved

    Including a taxonomy in a custom post type’s URL

    Hi. I’ve got a few CPTs and taxonomies set-up using ACF. For one CPT, ‘person’, I want to include a taxonomy, ‘team’, in the url structure. I was hoping ACF would accept taxonomy tags in the URL Slug field in the Advanced post type settings, but it doesn’t seem to be possible. I tried %team%/{slug}, {%team%}/{slug} and {team}/{slug} but none of these worked, unfortunately.

    Is this currently possible in ACF?

  • Helping

    How to sort taxonomy archive by ACF date field?

    The following code works with my custom post type “game”:
    function ptc_customize_wp_query( $query ) {
    if ( $query->is_post_type_archive( 'game' ) ) {
    // Sort portfolio posts by project start date.
    $query->set( 'order', 'DESC' );
    $query->set( 'orderby', 'meta_value_num' );
    // ACF date field value is stored like 20220328 (YYYYMMDD).
    $query->set( 'meta_key', 'release-date' );
    }
    }

    But my custom posts “Game” also have custom taxonomies like “genre”. How can I apply this sorting to these custom taxonomies as well?

  • Solved

    Field group not showing in backend since Woocommerce last update

    I use a field group to add informations to my WooCommerce products from the backend.
    The location rule is set to post taxonomy = a product_cat.
    It was working fine until I update to last WC version (8.2.1).
    Since this update, group field no longer appear on new product when clicking the checkbox of the corresponding product_cat neither is it listed in screen options.
    When editing an existing product, field group appear temporary but if I change any of its options based on taxonomy, it disappears.
    If I change the location rules of the field group to, for example, post type = product, it works normally, so it seems to be related to location rule.
    The issue only affect backend. On frontend everything is working fine.
    I set up a test site with only WooCommerce 8.2.1 and ACF 6.2.1 and the issue is there.

  • Solving

    Restrict editors from adding new terms to custom taxonomy

    I’ve created a custom taxonomy and attached it to a CPT.
    I’ve created terms for the taxonomy.

    I now want to place restrictions on how the editor can edit and assign terms for this particular taxonomy.

    I want to prevent editors from being able to add new terms.

    I also want to present editors with a choice of terms, from which they must select one.

    A radio button UI would be great for this.
    Is there a way to present existing terms for a custom taxonomy as radio buttons?

  • Helping

    Can I use a custom tax for a CPT permalink?

    Hello,

    I’d like a permalink structure like this for my custom post type: /%custom-tax%/news/

    Where %custom-tax% is the term for a custom taxonomy checked in the custom post.

    It’s like the core WordPress permalink where you can have the custom structure like /%category%/%postname%/

    Is it possible with ACF?

  • Helping

    How do I create custom terms for a custom taxonomy?

    I’ve created a custom taxonomy.

    Now I want to create terms for that taxonomy, and for the custom taxonomy I want to limit an editor to selecting from only among the custom terms.

    what I’ve tried

    I’ve successfully created a Taxonomy field.

    After that I start creating a Taxonomy Term field.
    But in the fields options, I cannot see a means to connect and restrict the Term to the custom Taxonomy that I’ve created.

    How do I do this exactly?

  • Helping

    Conditional logic on taxonomy field and term IDs in different environments?

    I’m using conditional logic on a taxonomy field (via term IDs) to show/hide additional fields that may/may not be required (based on the taxonomy term selected). No problems here.

    The problem I’ve run into, though, is that these term IDs change when they’re created in different environments (local, development, staging and production). And because I’m also using local JSON to store ACF fields, I can’t just update my conditional logic’s term IDs per-environment (as that’s all stored in the JSON files, in GIT, and staging/production don’t have write-access for these files and can only be updated via GIT).

    So, wondering if anyone else has run into this issue and if they’ve found a way to deal with this?

    Thanks,
    Kristin.

  • Helping

    Question for custom field radio button

    I have a case:
    I create a custom post type with name is “location” and create taxonomy with name is
    district. I use acf create a field radio button in taxonomy district. Then i get_field it, but it return null in spite of value

  • Solving

    Category Color

    Hey,

    I’ve set a ACF named “Category Color” with the following specs (see attach):
    – Field Type: Color Picker
    – Rules: Taxonomy IS EQUAL TO category

    Next, I set #b4151a as the “Category Color” value for a specific category (see attach).

    Lastly in Elementor I selected Background -> ACF Color Picker Field -> Category Color (see attach).

    Unfortunately there specified color is not reproduced in the frontend.

    Any ideas what I’m doing wrong?

    Thank you!

  • Solved

    acf/fields/post_object/query in Block

    I’ve built an ACF block which allows the user to embed a pre-built acf_form along with a few options. One of those options is selecting a taxonomy term (service-category) which will determine which services (post type) the end user can choose from in the ‘what service are you enquiring about’ field.

    However, I can’t figure out how to filter my acf_form field to show the services from the chosen taxonomy.

    I’ve used acf/load_field to filter the field args but this appears to be too late in the process and, while the amended arguments appear as I want them, the post_object field returns “The results could not be loaded”.

    I’m also filtering acf/fields/post_object/query but here don’t have access to any of the block (or post) data so can’t amend my query args according to saved meta.

    Finally, when logging the query args via acf/fields/post_object/query I can see that they are unchanged even when using acf/load_field which causes “The results could not be loaded” – so load_field is having some effect but not the desired one.

    Any pointers or ideas for making this work will be gratefully received.

  • Helping

    Taxonomy Fields and Conditional Logic for Multiple Terms

    The post from April of 23 requesting the same thing is marked solved but doesn’t seemed to be solved, or at least there doesn’t seem to be a satisfactory solution for one very common condition…

    https://support.advancedcustomfields.com/forums/topic/taxonomy-terms-in-conditional-logic/

    I asked about reusing fields in different groups each with different location settings and hube2 pointed me to the idea of using a Taxonomy Field and setting conditional logic with the subsequent fields. It like a very suitable solution.

    In that thread, as in the thread posted 3 months ago, hube2 says to use Selection is Greater than [term id-1], and Selection is less than [term id+1]. I found this only works when you have just one term ID selected, which is often not the case, especially when the taxonomy is hierarchical, and both parent and child are selected.

    Additionally, as part of this request, it’s worth point out that having to use ‘Greater Than’ and ‘Less Than’ a term ID is not ideal. There are instances in migration where a term id may need to change, but the slug(s) will remain the same.

  • 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

    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

    Field type taxonomy missing fields in BE when click create

    I have extended my custom taxonomy with an ACF field group and when I directly create or edit the custom taxonomy the additional fields from my ACF field group appears in the form but when I click create a new custom taxonomy from a field type taxonomy in any ACF form only the title and the parent field appears in the from but all the other fields are missing. Is this intentionally? It looks like because only 2 fields appears. I would expect also all the other fields. Can I change this?

  • 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 ?

Viewing 25 results - 101 through 125 (of 3,188 total)