Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

topic

  • Unread

    Taxonomy, need some clarifications

    Hello,

    Can someone please explain me the options of Save Terms (Connect selected terms to the post) and Load Terms (Load value from posts terms). And what are the implacations if I have them always on or always off?

    Thanks!

  • Solved

    Get Custom Taxonomy in Select Taxonomy Field Type with its Image

    Okay, so i have custom taxonomy and added custom image field using ACF.

    My question is, how can i get the name and image of the custom taxonomy using php function in the backend when i using the field groups?

  • Helping

    Filtering Taxonomy "Load Terms"

    I am working on a site that requires me to filter a series of taxonomies into a multi-select. I am able to properly filter the choices by using acf/fields/taxonomy/query. However, am I able to filter the “load terms” functionality? For instance, if a post has the following associated terms:
    – Term A
    – Term B
    – Term D

    And the filtered ACF taxonomy field is showing only:
    – Term A
    – Term D

    I’d like the “load terms” to only show Term A and D. Currently, it is showing all three despite Term B not being in the list.

    Is that possible? I don’t see any filters for the load terms functionality.

  • Solving

    Getting (and grouping) relation post object category

    Im in the following situation, i have custom post type called Materials which has a custom taxonomy material_category

    Then i have a custom post type called Doors with a custom field “material” that relate to one or more materials (specified above)

    When i create the single door page i have no problem to get all the related materials and print them out, also at the moment for each materia i get back i loop to get their category, then i store everything in a temporary object, order it by material_category and print it out to obtain somehhing like:


    Material:
    Wood: Walnut, Pine
    Marble: White
    Lacquered: Matte, Gloss

    I found this way quiete intensive (the door have multiple custom field with relation to other objects that need the same category getting and grouping action)

    so i was looking for a way to (at least) get the post object with its categories so that i dont need to re-query each result.

    probably i can filter on ‘acf/fields/post_object/result’ but i cant find how
    any suggestion?

  • Unread

    Changing a shortcode so it links an individual product based on its taxonomy

    On my website I have a “Products” custom post type, that lists different Amazon products. There are various product categories (mouse, keyboard, monitor etc), which I differentiate using a custom taxonomy (“product_category”).

    To display the products on the frontend, I use an ACF “post object” field type to select an individual product, and output them in the form of a text link. The shortcode I am using to achieve this is:

    
    global $wpdb;
        
        $faqTitleUrl = "";
        $faqProData = shortcode_atts( array(
                'field' => 'what_controller'
    ,            ), $atts );
         $faqPostID = get_field( $faqProData['field'] );
        
         if($faqPostID !=''){
         $faqPostTitle = get_the_title($faqPostID);
         $faqPostUrl   = get_field('product_link',$faqPostID);
         $faqProductTitleUrl = '<a href="'.$faqPostUrl.'" target="_blank">'.$faqPostTitle.'</a>';
         }
         
        return $faqProductTitleUrl;
    }
    
    add_shortcode('faq_product', 'faq_product');
    

    I then use [faq_product field=”FIELD_NAME”] shortcode to display the link. This is working fine, but only when the ACF post object field is set up to display a single entry.

    What I would like to do is turn on ACFs “Select multiple values?” feature to allow me to have multiple products selected, and then edit the above code so it is able to display only one of these product links, based on the category I choose.

    As an example, my post object field has the following products:

    | Product 1 (Mouse Category) | | Product 2 (Keyboard category) | | Product 3 (Monitor category) |

    If I wanted to just display the link to the mouse on the frontend, I could use a shortcode, with something along the lines of [faq_product cat=”MOUSE” field=”FIELD_NAME”]

    I’d really appreciate it if someone could help edit the shortcode to allow for this.

    Many thanks.

  • Helping

    Show Post of a Category with Taxanomy field ACF

    hi
    I want to get the ID of a category from the taxonomy field and display its contents based on the following code, but in output only that number is printed and the posts
    I want the category ID I specified to be stored in the $get_cat_id variable and be in the array entered :

    										<?php
    												// Check rows exists.
    												if( have_rows('functions_tabs') ):
    													$counter = -1;      
    													$count = 0;
    												// Loop through rows.
    												while( have_rows('functions_tabs') ) : the_row();
    												$term_id = 92;
    												$counter++ ; 
    												$get_cat_id = the_sub_field('select_category');
    												
    										?>
                            <div class="tab-pane fade <?php if (!$count) {?> show active <?php }?>" id="v-pills-<?php echo $counter;?>">
    						
    								 <?php $args= array('post_type' => 'products',
    								 'post_status' => 'publish',
    								 'orderby' => 'title',
    								 'order' => 'DESC',
    								 
    									'tax_query' => array( array( 'taxonomy' => 'categories',
    								
    									'field' => 'id',
    									
    									'terms' => array($get_cat_id) ) ) );
    									
    
    									$result = new WP_Query( $args ); if ( $result->have_posts()):?>
    
    								 	<div class="function-top p-4">
    									<h3><?php the_sub_field('name_tab_functions'); ?></h3>
    									 <p class="m-0"><?php echo category_description(); ?>
    
    								 </div>	
    								 
    								 <?php while ( $result->have_posts()) :$result->the_post();?>
    
    							<a href="<?php the_permalink(); ?>" class="function-link"><div class="function">
    									<div>
    										<?php if(has_post_thumbnail()){
    											the_post_thumbnail('thumb300170',array('alt'=>''.get_the_title(),'class'=>'function-img','title'=>''.get_the_title().''));
    
    												} else { ?>
    													<img src="<?php bloginfo('template_url');?>/images/no-thumbnail.jpg" class="function-img">
    										<?php } ?>
    									</div>
    									<div class="function-content px-4">
    										<h4 class="function-title"><?php the_title();?></h4>
    										<p class="function-desc"><?php echo excerpt(35);?>...
    
    									</div>
    								</div></a>
    							<?php   endwhile; 
    											
    									endif;  wp_reset_query();				 
    							 ?>
                            </div>
    						<?php 
    							$count++;
    						  endwhile;
    						endif; 
    					 ?>   
  • Helping

    custom category

    I have created a category with this code

    
    function custom_post_type() {
    
    // Set UI labels for Custom Post Type
    $labels = array(
    'name'                => _x( 'products', 'Post Type General Name', 'twentythirteen' ),
    'singular_name'       => _x( 'product', 'Post Type Singular Name', 'twentythirteen' ),
    'menu_name'           => __( 'Products', 'twentythirteen' ),
    'parent_item_colon'   => __( 'Parent Product', 'twentythirteen' ),
    'all_items'           => __( 'All products', 'twentythirteen' ),
    'view_item'           => __( 'View Product', 'twentythirteen' ),
    'add_new_item'        => __( 'Add New Product', 'twentythirteen' ),
    'add_new'             => __( 'Add New', 'twentythirteen' ),
    'edit_item'           => __( 'Edit Product', 'twentythirteen' ),
    'update_item'         => __( 'Update Product', 'twentythirteen' ),
    'search_items'        => __( 'Search Product', 'twentythirteen' ),
    'not_found'           => __( 'Not Found', 'twentythirteen' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),
    );
    
    // Set other options for Custom Post Type
    
    $args = array(
    'label'               => __( 'products', 'twentythirteen' ),
    'description'         => __( 'product news and reviews', 'twentythirteen' ),
    'labels'              => $labels,
    // Features this CPT supports in Post Editor
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields','tags' ),
    // You can associate this CPT with a taxonomy or custom taxonomy.
    'taxonomies'          => array( 'genres' ),
    /* A hierarchical CPT is like Pages and can have
    * Parent and child items. A non-hierarchical CPT
    * is like Posts.
    */
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
    );
    
    // Registering your Custom Post Type
    register_post_type( 'products', $args );
    register_taxonomy('categories', array('products'), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => array( 'slug' => 'products', 'with_front'=> false )));
    
    }
    
    /* Hook into the 'init' action so that the function
    * Containing our post type registration is not
    * unnecessarily executed.
    */
    
    //create two taxonomies, genres and tags for the post type "tag"
    function create_tag_taxonomies() 
    {
      // Add new taxonomy, NOT hierarchical (like tags)
      $labels = array(
        'name' => _x( 'Tags', 'taxonomy general name' ),
        'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Tags' ),
        'popular_items' => __( 'Popular Tags' ),
        'all_items' => __( 'All Tags' ),
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edit Tag' ), 
        'update_item' => __( 'Update Tag' ),
        'add_new_item' => __( 'Add New Tag' ),
        'new_item_name' => __( 'New Tag Name' ),
        'separate_items_with_commas' => __( 'Separate tags with commas' ),
        'add_or_remove_items' => __( 'Add or remove tags' ),
        'choose_from_most_used' => __( 'Choose from the most used tags' ),
        'menu_name' => __( 'Tags' ),
      ); 
    
      register_taxonomy('tag','products',array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'update_count_callback' => '_update_post_term_count',
        'query_var' => true,
        'rewrite' => array( 'slug' => 'tag' ),
      ));
    }
    
    add_action( 'init', 'create_tag_taxonomies', 0 );

    How can I display the list of posts of that taxonomy using the َACF plugin’s taxonomy feature?

    https://www.advancedcustomfields.com/resources/taxonomy/

  • Solved

    Category list not working inside of while loop

    I’ve got a rather simple section that is made up of a single repeater (category_articles) that contains two fields, a headline (headline) and a taxonomy selector (post_category, returns Term ID).

    Here’s the code block I’m using:

    
    <section class="multi_column_articles">
        <div class="container">
            <div class="row">
                <?php  if( have_rows('category_articles') ):
                    while( have_rows('category_articles') ): the_row(); 
                    $headline = get_sub_field( 'headline' );  //text headline
                    $post_category = get_sub_field( 'category' ); //category ID
                ?>
                <div class="col">
                    <h4><?php echo $headline; ?></h4>
                    <?php 
                    $args = array( 'category' => $post_category, 'post_type' =>  'post' ); 
                    $postslist = get_posts( $args ); //get posts in specified category
                    foreach ($postslist as $post) : setup_postdata($post); ?>
                        <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
                    <?php endforeach; ?>
                </div>
                <?php endwhile; 
                endif;?>
            </div>
        </div>
    </section>
    

    The problem I’m running into is the while loop only appears to go through one time and then quits. I’ve got three categories set up and have posts in each category. On the page I want it to display each category list in a column with the ability to add/remove columns later on.
    I’ve tested the while loop without the post list in it and it works fine, I’ve also tested the post list by itself (with multiple categories at the same time) and it also works fine.
    Has anyone else run into an issue like this?

  • Solved

    HELP: Filtering by ACF field in Archive

    Hi All,

    I have a CPT with an ACF group to build case studies (projects). One of the fields in the case study is a checkbox list of ‘disciplines’ pulled from a custom taxonomy.

    I can display a full archive (/projects/), and I can display individual projects (/project/my-project-1) without issue.

    In the individual project display, I have added a link to the key disciplines to link them to /projects/discipline=Discipline%20Name

    on the archive page I have added the following to try and only display projects tagged with the discipline:

    // args
    if (!$_GET['discipline']) :
    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'case_study',
    );
    else :
    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'case_study',
    	'meta_query'	=> array(
    		'key'		=> 'discipline',
    		'value'		=> $_GET['discipline'],
    		'compare'	=> 'IN',
    	)
    );
    
    endif;
    
    var_dump($args);
    
    $the_query = new WP_Query( $args );
    
    // display project list 
    

    The $args dump looks correct:

    `array(3) {
    [“numberposts”]=> int(-1)
    [“post_type”]=> string(10) “case_study”
    [“meta_query”]=> array(3) {
    [“key”]=> string(10) “discipline”
    [“value”]=> string(20) “This Discipline”
    [“compare”]=> string(2) “IN” }
    }

    but the query isn’t affected and still displays all projects in the list.

    Where am I going wrong?

    I don’t need ‘live filtering’, just the link in a single project to be able to show a list of all projects in the same discipline.

    Any pointers would be awesome – scoured the main docs, but can’t find any clues.

    Ben

  • Helping

    "Plus" button missing in taxonomy field

    Hi,

    I have a problem with the taxonomy field on my form.
    Non logged in users don’t see the plus button on the right side of the field, they can’t add new items to the field, only select from the list.
    There is no problem when I’m admin on the page.
    How can I display this button everytime?

    Thanks in advance.

  • Solving

    UL list from custom taxonomies

    Have multiple ACF galleries with 100+ items. Each image attachment has simple custom taxonomy (artist). No problem getting the taxonomy term for an individual item. But, how can I count the individual values of the terms and create a ul list based of ONLY the unique values? Count would be good too, but not necessary. Ie, artist1 (3), artist2 (4), etc. get_terms() doesn’t work since all artists may not appear within the current query loop.

  • Solved

    Limit radio button options

    Hi guys,

    think this is going to need php from what i have worked out and im a total beginner.

    im using a taxonomy field with radio button appearance, my site has over 500 different custom tags but this field needs to only show 4 of them from the list.

    i know the tag ids of the 4 tags but i have no idea what i am doing, i have set up a child theme

    so my field label is “card type”

    and i want the only 4 options to be

    battle (tag id 133)
    extra (tag id 268)
    leader (tag id 381)
    unison (tag id 635)

    i have read many similar posts but cannot wrap my head around how i should alter them to fit my needs if someone could just give me a push in the right direction that would be great.

    if you provide a code solution would you be able to explain how and why we do it that way so i may try to learn from it.

    Kind Regards

    emeraldedge

  • Solving

    Sorting the results of taxonomy field

    We are trying to sort the results listed in a Taxonomy field of ACF. The words that we want to display as suggestions are added in a terms/taxonomy called Ingredients. Currently the terms are sorted alphabetically. However, we would like to implement a custom sorting rule where the results that start with the typed in part are listed on top of the list, followed by other suggestions. For example, if looking for we are searching for “sugar” the results would be something like:

    – sugar
    – sugar powder
    – brown sugar
    – palm sugar
    – …etc

    I know how to implement the sorting algorithm in PHP. However, the issue is where to place the code so that this change will be reflected in the WordPress admin panel when editing posts. I’ve added a picture to this post to visualize the part that we want to change.

    Any ideas? We’ve already tried Custom Taxonomy Order addon, but that one does not allow for custom sorting in code: https://wordpress.org/plugins/custom-taxonomy-order-ne/ and

    ACF taxonomy

  • Solving

    How to auto select ACF relationship field based on taxonomy selection

    Hello Guys,

    I have recently moved away from Joomla and starting using WP because of ACF. I think it is great.

    Currently I am working on a project where we have custom taxonomy called ‘Authors’, but we have decided to removed it and use custom post type instead. So, I have created a new custom post type called ‘Journal Authors’ and converted all of the taxonomy ‘Authors’ into the new custom post type.

    In ACF I have created a ‘relationship’ field type and filtered by this new ‘Journal Authors’ custom post type and applied it to the Posts.

    Now, my question is how can I automatically select the ACF ‘Journal Authors’ based on the ‘Authors’ taxonomy selection? We don’t want to open each post and select manually.

    I hope my explanation make sense. Please see the screenshots.

    I would be very grateful if you could please provide little help.

    Many Thanks
    Karen

  • Helping

    Load Value from Post Terms – Not Working

    @elliot I am facing the same issue with version 5.9.5 as described in this thread.

    I have created a field “property_city” related to my custom taxonomy “city”. I have checked the option of Save Terms and Load Terms.

    Save Terms works while Load Terms does not work.

    Details: Editing the taxonomy field saves the terms as custom taxonomy as well. However, taxonomy field does not load the terms already selected from custom taxonomy. Also, editing from custom taxonomy does not save the terms in neither taxonomy field nor custom taxonomy.

    So, essentially the ACF taxonomy field completely overrides the Taxonomy metabox as opposed to working together.

    I would like to be able to edit the city from both taxonomy metabox and the taxonomy field.

    I have been trying to dig into ACF code to identify the function where I could change get_fields to get_the_terms as suggested by you in the thread referenced above. However, I had no luck with that. I do not have programming knowledge, can only make tweaks when guided.

    Any help would be appreciated. Thank you!

  • Solved

    Problem with WP_Query with Custom Taxonomy Types

    I’ve created a custom taxonomy type named ‘div2’ and I want to use it in WP_Query.
    The problem is that I cannot make it work properly.
    This is my code:

    
            $args = array(
                'post_type' => 'vd_equipos',
                'posts_per_page' => $cantidad,
                'orderby' => 'title',
                'order' => 'ASC',
            'tax_query' => array(
                array(
                    'taxonomy' => 'category',
                    'field'    => 'slug',
                    'terms'    => 'primera-division',
                ),
            ),
            );
    

    But shows no data. Maybe the problem is in the ‘tax_query’ definition, I really do not know

  • Helping

    Location Rules for any Taxonomy page with Parent element

    Hi !

    I would like to display some fields on the Taxonomy page (not on the post page) and be able to select the Taxonomy itself (not the taxonomy type like ACF does).

    Example:
    I have some custom Taxonomy called ‘Rubrique’ which has ‘Radar’ inside it.
    I would like to add these fields only on the ‘Radar’ taxonomy page (in the back-office).

    I have checked this, but couldn’t find my solution :
    https://github.com/Hube2/acf-filters-and-functions

    Thanks!
    Vianney.

  • Solved

    Get ACF image array from taxonomy term

    Hi

    I am having some issues getting an ACF image field (array) from a taxonomy and displaying it in a loop on a page.

    I am looping through the Taxonomy terms with the following code. Its showing the term name and description no problem, but its not picking up the ACF field. Any ideas?

    <?php
    $terms = get_terms(
    array(
    ‘taxonomy’ => ‘tipo_reparacion_mob’,
    ‘hide_empty’ => false,
    )
    );

    $repair_icon = get_field(‘repair_type_icon’, $terms . ‘_’ . $term_id);

    if ( ! empty( $terms ) && is_array( $terms ) ) {
    foreach ( $terms as $term ) { ?>
    <div class=”swiper-slide”>
    <div class=”swiper-slide-inner”>
    <?php if( !empty( $repair_icon ) ): ?>
    <div class=”swiper-slide__icon”>
    ” alt=”<?php echo esc_attr($repair_icon[‘alt’]); ?>” />
    </div>

    <?php endif; ?>
    <h3 class=”heading–tertiary heading–mb-sm”>
    <?php echo $term->name; ?>
    </h3>
    <p>
    <?php echo $term->description; ?>
    </p>
    </div>
    </div>

    <?php
    }
    }
    ?>

    Thanks

  • Solving

    Field name 0(Zero) doesn't save data.

    Field name 0(Zero) doesn’t save data and Field Label 0 isn’t being displayed. I looked closely and found out Field name ‘0’ doesn’t have data-name attribute.
    https://i.imgur.com/QL3fTme.png

    Field name 0 in Edit Field Group page:
    https://i.imgur.com/vvl4xp3.png

    Field name 0 after saving in the selected location or taxonomy:
    https://i.imgur.com/uMVJjhE.png

    What can be the problem here? I have been using ACF Version 5.9.0. Thank you.

  • Solved

    Display ACF from specific Taxonomy

    Hi. I am creating a website using CPT UI and ACF.
    I have created a CPT called ‘repairs’. Inside this CPT I have created 2 taxonomies:
    ‘repair_type’ and ‘product_brand’.

    Each post is related to a repair type (e.g. Screen replacement, battery replacement, case repair, etc.. ) and also a brand (e.g. Apple, Samsung, Sony, etc..).

    Inside a taxonomy ‘repair_type’ I have a ACF field called ‘repair_price’. This field appears no problem in the admin for each repair type. My issue is that I would like to display this field in the ‘repairs’ post. I have tried modifying the single.php file to display this using:

    <?php $term = get_field(‘repair_price’); ?>
    <?php the_field(‘repair_price’, $term); ?> €

    But the field doesn´t show. I think that maybe, as the post is linked to 2 taxonomies I may have to specify exactly which taxonomy term I need to pull the data from?

    I have also tried:

    $term = get_queried_object();
    $price = get_field(‘repair_price’, $term);
    <?php echo $price; ?>;

    but this also does not work.

    Any ideas. Appreciate any help

  • Solving

    Setting Parent Posts from Frontend

    Hi there, long time lurker… generally tend to get the job done from snippets I find around here, but this has been racking my brain for a good few weeks. How can I set a parent post from the frontend? I am using elementor and acf front end with great success, but we are looking to add hierarchical support for a custom post type called myJournals. We would like to give users the ability to link parent journals but can’t seem to make it work. We have ‘hierarchical’ => true so it is working in the backend, but all of our users including editors will be limited to front-end access only.

    We have set a relationship field within ACF called related_journals and have tried numerous things in the functions.php to make it work. Any chance you guys could throw us a bone and point us in the right direction?

    Also, how would I go about adding a taxonomy term from a field to the post title upon creation? We would like a pre-fix added onto post title and name but it only returns taxonomy number and not the name

  • Solving

    Create new field group

    I want o create new field group People. I am using the following code but in the back-end nothing created.

    
    f ( function_exists( 'acf_add_local_field_group' ) ) {
    
    		// ACF Group: People
    		acf_add_local_field_group( array (
    			'key'      => 'group_person_details',
    			'title'    => 'Person Details',
    			'location' => array (
    				array (
    					array (
    						'param'    => 'post_type',
    						'operator' => '==',
    						'value'    => 'person',
    					),
    				),
    			),
    			'menu_order'            => 0,
    			'position'              => 'normal',
    			'style'                 => 'default',
    			'label_placement'       => 'top',
    			'instruction_placement' => 'label',
    			'hide_on_screen'        => '',
    		) );
    
    		// First name
    		acf_add_local_field( array(
    			'key'          => 'field_first_name',
    			'label'        => 'First Name',
    			'name'         => 'first_name',
    			'type'         => 'text',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 1,
    		) );
    
    		// Middle name
    		acf_add_local_field( array(
    			'key'          => 'field_middle_name',
    			'label'        => 'Middle Name',
    			'name'         => 'middle_name',
    			'type'         => 'text',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 0,
    		) );
    
    		// Last name
    		acf_add_local_field( array(
    			'key'          => 'field_last_name',
    			'label'        => 'Last Name',
    			'name'         => 'last_name',
    			'type'         => 'text',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 1,
    		) );
    
    		// Image
    		acf_add_local_field( array(
    			'key'           => 'field_image',
    			'label'         => 'Image',
    			'name'          => 'image',
    			'type'          => 'image',
    			'parent'        => 'group_person_details',
    			'instructions'  => '',
    			'required'      => 0,
    			'return_format' => 'array',
    			'preview_size'  => 'thumbnail',
    			'library'       => 'all',
    			'min_width'     => 0,
    			'min_height'    => 0,
    			'max_width'     => 0,
    			'max_height'    => 0,
    		) );
    
    		// Office
    		acf_add_local_field( array(
    			'key'          => 'field_office',
    			'label'        => 'Office',
    			'name'         => 'office',
    			'type'         => 'text',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 0,
    		) );
    
    		// E-mail
    		acf_add_local_field( array(
    			'key'          => 'field_email',
    			'label'        => 'E-mail',
    			'name'         => 'email',
    			'type'         => 'email',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 0,
    		) );
    
    		// Office Phone
    		acf_add_local_field( array(
    			'key'          => 'field_phone',
    			'label'        => 'Phone',
    			'name'         => 'phone',
    			'type'         => 'text',
    			'parent'       => 'group_person_details',
    			'instructions' => '',
    			'required'     => 0,
    		) );
    
    		// Affiliation
    		acf_add_local_field( array(
    			'key'             => 'field_affiliation',
    			'label'           => 'Affiliation',
    			'name'            => 'affiliation',
    			'type'            => 'taxonomy',
    			'parent'          => 'group_person_details',
    			'instructions'    => '',
    			'required'        => 0,
    			'taxonomy'        => 'affiliation',
    			'field_type'      => 'multi_select',      // UI (checkbox, multi-select, select, radio)
    			'allow_null'      => 0,             // Can select a blank value
    			'load_save_terms' => 1,             // Persist using term relationships table
    			'return_format'   => 'object',      // or 'object'
    			'add_term'        => 0,             // Can the user add new terms?
    		) );
    	}
    }
    
    add_action( 'acf/init', 'register_custom_acf_fields' );
    
  • Helping

    ACF Taxonomy – Load terms in order they are entered?

    Right now, when you enable “Load Terms” for acf taxonomy field, it will automatically load all terms from that specific taxonomy into acf’s taxonomy field. I love this feature, but it orders the terms by term_id. When you manually select terms, they are displayed in the order you selected. Is there a way to “load terms” into acf’s taxonomy field in order they are entered in the default wp taxonomy field?

  • Helping

    Don't show fields on Taxonomy 'add' form.

    Haven’t been able to find anyone discussing this, I would like to omit any ACF custom fields from the “Add” taxonomy term field and only show them on the edit term page. It’s just a bit too much to display in the add form.

    Thanks.

  • Solved

    Taxonomy field return used in post query

    I am trying to create several areas in a site which show 2 recent posts from a specific category, and I want to use a ACF fields to allow the site admin to choose/change the category displayed.

    I have set up a group of taxonomy fields – settings as follows:

    • Taxonomy: Category
    • Appearance: Select
    • Return Value: Term Object

    I am implementing these fields as follows:

    
    <?php if(have_rows('page_sections')) : while(have_rows('page_sections')) : the_row(); ?>
     
     <?php 
      $cat = get_sub_field('category');
      $cat_id = esc_html( $cat->ID );
      $cat_args = array(
       'cat' => $cat_id,
       'nopaging' => false,
       'posts_per_page' => 2,
       'ignore_sticky_posts' => 1
      );
      $cat_query = new WP_Query( $cat_args );
      if ( $cat_query->have_posts() ) : ?>
      <h3><a href="<?php echo esc_url( get_term_link( $cat ) ); ?>"><?php echo esc_html( $cat->name ); ?></a></h3>
      <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); ?>
       <!-- Displaying post data here -->
      <?php endwhile; ?>
      <?php wp_reset_postdata(); ?>
     <?php else : endif; ?>
    
    <?php endwhile; ?>
    <?php else : endif; ?>
    

    My issue is that the cat => part of the query makes no difference to the result. I am getting the 2 most recent posts of all categories rather than the specified one.

    How do I get the term object from the sub field to filter my query?

    Thanks.

Viewing 25 results - 451 through 475 (of 3,191 total)