Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

topic

  • Unread

    Taxonomy inside repeater in categories

    In ‘Product Categories’ I’ve created a repeater called upsells and inside is a taxonomy called ‘Category’.

    It works fine in the admin area, as can select which categories I want. However, I can’t get them to appear in the repeater…

    <?php 
    	$term = get_queried_object();
    	if( have_rows('upsells') ): 
    ?> 
        <?php while( have_rows('upsells') ): the_row(); 
            $category = get_sub_field('category', $term);
        ?> 
        	<?php echo $category; ?>
        <?php endwhile; ?>        
    <?php endif; ?> 
    <?php wp_reset_query(); ?>
  • Unread

    How to show ACF taxonomy in my website?

    hello,

    I created custom taxonomy field to my delivery type, it will show in WordPress product page. But I need to show it in my website vendor product add page. I tried so many things but nothing help me, I’m stuck in this problem over month. If it is possible to help me really appreciate it.

    Thanks for your time.

  • Unread

    Get sub_field not working as expected.

    Front end challenge.. insights needed.

    Using acf to create custom landing pages > landing.php (works as expected)

    function landing_do_acf_content() {
    if( have_rows('landing_page_content') ) { ?>
    
    <section class="landing-content">
    <?php while ( have_rows('landing_page_content') ) : the_row();
    
    if( get_row_layout() == 'intro_text' ) { ?>
    <?php include('partials/blocks/intro_text.php');?>
    <?php }
    
    else if( get_row_layout() == 'highlights' ) { ?>
    <?php include('partials/blocks/highlight.php');?>
    <?php }

    Most blocks are constructed to allow for some user customization.
    including color and layout
    (most work as expected)

    <?php include('color.php'); ?>
    
    <section id="<?php the_sub_field( 'headline' ); ?>" class="">
      <div class="container p-16 mx-auto flex flex-wrap <?php echo $c1; ?> <?php echo $bg1; ?>">
        <?php if ( get_sub_field('headline') ) : ?>
          <div class="block min-w-full">
          <h3 class="my-10 mt-0 font-bold tracking-normal text-center is-all-caps <?php echo $c1; ?> "><?php the_sub_field( 'headline' ); ?></h3>
          </div>
      <?php endif; ?>
        <div class="flex flex-wrap flex-grow -m-4">
          <?php if ( have_rows( 'highlight' ) ) : ?>
            <?php while ( have_rows( 'highlight' ) ) : the_row(); ?>
              <div class="p-4 lg:w-1/2 md:w-full sm:w-full">
                  <p class="text-8xl font-black text-center <?php echo $c1; ?>"><?php echo get_sub_field('large_text'); ?>
    
                  <p class="text-4xl font-regular text-center <?php echo $c1; ?>"><?php echo get_sub_field('small_text'); ?>
    
              </div>
                  <?php endwhile; ?>
                <?php else : ?>
                  <?php // no rows found ?>
                <?php endif; ?>
        </div>
      </div>
    </section>

    Here’s the challenge.
    I have a color.php which grabs the background choice
    and adds a background and text color to the class=

    <?php
    $bg = get_sub_field('background_color');
    if ($bg == '#000000') :
    $bg1= 'white-c-bg';
    $c1 = 'charcoal-c-t';
    elseif ($bg == '#96c0ce'):
    $bg1 = 'babyblue-c-bg';
    $c1 = 'white-c-t';
    elseif ($bg == '#000000'):
    $bg1 = 'black-c-bg';
    $c1 = 'white-c-t'; ?>
    <?php else : ?>
      <?php
      $bg1 = 'transparent';
      $c1 = 'charcoal-c-t'
      ;?>
    <?php endif; ?>

    The color.php works great on most of the blocks.
    But I have a block that queries pages and the color.php doesn’t work as expected.

    
    <?php
    include('color.php');
    $link = get_sub_field('site_link');
    $linktext = get_sub_field('site_link_text');
    global $post;
    $position = get_sub_field('random_profile_type');
    $args = array(
      'post_type'=>'profile',
      'showposts'=>'1',
      'orderby'=>'rand',
      'tax_query'=> array( array(
      'taxonomy' => 'profile_type',
      'field' => 'slug',
      'terms' => $position,
      'operator' => 'IN',
    ), ),
    );
    $testimonials=new WP_Query($args);
    while ($testimonials->have_posts()) : $testimonials->the_post();
    // Display post details here. Example: the_title(), the_permalink(), etc.
    {
    $affiliation = get_field( 'affiliation' );
    $cred = get_field( 'credentials' );
    $image = get_field( 'headshot' );
    $snippet = get_field( 'testimonial-snippet' );
    $testimonial = get_field( 'testimonial' );
    $short = get_field( 'testimonial-short' );
    $page = get_the_ID();
    $title = get_the_title($page);
    }
    ?>
    
    <section>
    <div class="px-4 py-16 mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-24 lg:px-8 lg:py-20 <?php echo $bg1; ?> <?php echo $c1; ?>">
    <div class="max-w-xl mb-10 md:mx-auto sm:text-center lg:max-w-2xl md:mb-12">
        <div>
          <p class="inline-block px-3 py-px mb-4 text-xs font-semibold tracking-wider text-teal-900 uppercase rounded-full bg-teal-accent-400">
            <?php if($testimonial && !$short) { ?><p><?php echo $testimonial; ?></p>
            <?php } ?>
            <?php if($testimonial && $short) { ?><p><?php echo $short; ?></p>
            <?php } ?>
          </p>
        </div>
      </div>
      <div class="max-w-lg mb-10 mx-auto md:mb-12">
        <div class="flex">
          <?php echo wp_get_attachment_image( $image, 'medium',null, array( 'class' => 'object-cover w-40 h-40 mr-4 rounded-full shadow' ) ); ?>
          <div class="flex flex-col justify-center">
            <p class="text-lg font-bold"><?php echo $title; ?></p>
            <?php if( $cred && $affiliation ) { ?>
            <p class="text-sm text-gray-800"><?php echo $cred; ?></p><p class="twnb-affiliation-2"><?php echo $affiliation; ?></p>
            <?php } ?>
          <?php if( $cred && !$affiliation ) { ?>
            <p class="text-sm text-gray-800"><?php echo $cred; ?></p>
          <?php } ?>
          <?php if( $affiliation && !$cred ) { ?>
            <p class="text-sm text-gray-800"><?php echo $affiliation; ?></p>
          <?php } ?>
          </div>
        </div>
      </div>
      </div>
      </section>
    <?php
    endwhile;
    wp_reset_postdata();
    ?>

    Pretty much a noob here. Am I trying to do something that isn’t possible to do?

  • Solved

    Data is there but only visible after update

    Hi!

    I have imported some data and mapped it to the right fields I created with ACF (packaged with Avada). That import is not the issue. Afterwards I check and all the data is there. Nevertheless when I check front-end no data is showing. I need to go to the post in the backend and update it before the content will show front-end.

    Now at this point I thought, why not do a bulk edit.. that should do the trick. But no joy… that is not working.

    This is only happening with the taxonomy field.

    So maybe some wrong code there? Let me show you:

    
    <?php while ( have_posts() ) : ?>
    	<?php the_post(); ?>
    		<article id="post-<?php the_ID(); ?>" <?php post_class( 'post' ); ?>>
    			<div class="post-content">
    				<?php if( get_field('titel') ): ?><h1><?php the_field('titel'); ?></h1><?php endif; ?>
    				<?php if( get_field('omschrijving') ): ?><p><?php the_field('omschrijving'); ?></p><?php endif; ?>
    
    				<!-- The php below is to list the taxonomy 'categorie' -->
    				<?php 
    					$terms = get_field('categorie');
    					if ( !empty( $terms ) && !is_wp_error( $terms ) ){
    					 echo "<ul>";
    					 foreach ( $terms as $term ) {
    					   echo "<li>" . $term->name . "</li>";
    					
    					 }
    					 echo "</ul>";
    					}
    				?>
    
    				<!-- The php below is to list the taxonomy 'categorie' -->
    				<?php 
    					$terms = get_field('maker');
    					if ( !empty( $terms ) && !is_wp_error( $terms ) ){
    					 echo "<ul>";
    					 foreach ( $terms as $term ) {
    					   echo "<li>" . $term->name . "</li>";
    					
    					 }
    					 echo "</ul>";
    					}
    				?>
    
    			</div> <!-- post-content -->
    		</article>
    <?php endwhile; ?>
    
    

    Now i’m not that great with php… so could really be possible that it is the code for pulling the content from the custom taxonomies.

    Thanks for any help.
    Paul

  • Helping

    WooCommerce widget with ACF included

    I have created a taxonomy for Woo product attributed (colour).

    On the achieve page, I’ve added a widget to filter by colour.

    I want to adjust the filter to include the ACF field colour as well. But, so far I’ve been unable to find a solution.

    Can anyone assist, please?

  • Unread

    Location Rule where taxonomy is any of taxonomy's children

    I would like for a field group to be located on any post of which the taxonomy is jazz or any of it’s children (Bebop, Big Band, etc)

  • Solved

    Not getting color for category labels using custom taxonomy

    I have tried to implement this https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/

    This is my current code wich returns no color whatsoever.

    <ul>				
    <?php
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;				
    $term_id = $queried_object->term_id;  
    $color = get_field('color_de_fondo_categoria_tienda', $taxonomy . '_' . $term_id);	
    
    $cat_array = ( get_the_terms( get_the_ID(), 'categorias_tienda') );
    	foreach ( $cat_array as $cat  ) {
            if($cat->name != 'Destacados') { // the term ID you want to exclude
                echo '<li style="color:' . $color .';">' . $cat->name . '</li>';
            }
         }
     ?>
     </ul>

    do note it is in a regular page template such as “index”.

  • Unread

    Custom Archive page – how to display custom fields for taxonomy: category?

    Hey guys,

    I’m running into a similar issue as this one asked a long time ago.

    I have a grid where I want to display a category name, a thumbnail and the month of that category. I’ve already succeeded displaying it for one category but I’d like to be able to display it for every coming category without having to hard code it.

    Here’s a snippet:

    <ul class="bycategories">
    <div class="category-info">
    	<?php wp_list_categories('exclude=6,3&title_li='); ?>
    
    	
    	<?php if( get_field('issues_date', 'category_8') ): ?>
    						<h3 class="archive-title", >	<?php the_field('issues_date', 'category_8'); ?></h3>
    							<?php endif; ?>
    	</div>
    	
    				<?php if( get_field('thumbnail-cat', 'category_8') ): ?>
    	<a href="<?php the_permalink(); ?>">
    		<img class="archive-tb" src="<?php the_field('thumbnail-cat', 'category_8'); ?>" alt="" /></a>
    				<?php endif; ?>
    	
    </ul>

    I’ve tried many of the solutions online and even tried to follow along this doc to no avail, I want to be able to display each category’s fields as I create them for each post.

    For reference, I’m attaching a picture of the front end as well. The idea is that each category will display on the grid as it is created with the input of the fields:

  • Unread

    Images Conditional on Term

    I have a custom post type Vendors and custom taxonomy, Vendor Categories. A Vendor can be in multiple Vendor Categories and will have a different image for each Vendor Category.

    Each Vendor Category has its featured image, but each Vendor has an image for each of the Vendor Categories it is assigned.

    Acme Co is in Widgets, Explosives, Desert Survival. For each category, Acme has an image:
    acme_co-widgets.jpg
    acme_co-explosives.jpg
    acme_co-desert_survival.jpg

    I can create a Field Group conditional on selected terms so that an image selector is displayed for each selected Vendor Category. However, I would need to create a Field Group for any future Vendor Categories… and this just seems like a clunky solution.

    Is there a better way to (dynamically?) create an image field for each selected category? Can I use a single Field Group for this?

    Thank you

  • Solved

    Display Taxonomy Name from Inside Repeater Field

    Using:
    ACF 5.9.4
    WP 5.6

    How do you separate each taxonomy term (on the front-end) when there are multiple terms with a comma separator? Using this page as reference: https://www.advancedcustomfields.com/resources/taxonomy/

    <?php
    $terms = get_sub_field('message_speaker');
    if( $terms ):
    foreach( $terms as $term ):
    echo esc_html( $term->name );
    endforeach;
    endif;
    ?>
  • Unread

    ACF gutenberg tag field doesn't save

    Your support system is down……

    Hi there,
    I have a problem with ACF Gutenberg blocks not working in specific case.
    I want to be able to select specific news + specific tags.
    So I created this field:

    acf_add_local_field_group(array(
            'key'                   => 'group_5cbe885ee190f',
            'title'                 => 'Block: Related content',
            'fields'                => array(
                array(
                    'key'               => 'field_5cbe88701e944',
                    'label'             => 'Related case studies',
                    'name'              => 'related_case_studies',
                    'type'              => 'post_object',
                    'instructions'      => 'Select related case studies',
                    'required'          => 0,
                    'conditional_logic' => 0,
                    'wrapper'           => array(
                        'width' => '',
                        'class' => '',
                        'id'    => '',
                    ),
                    'post_type'         => array(
                        0 => 'post',
                    ),
                    'taxonomy'          => '',
                    'allow_null'        => 0,
                    'multiple'          => 1,
                    'return_format'     => 'id',
                    'ui'                => 1,
                ),
                array(
                    'key' => 'field_5cbe43102f4e6',
                    'label' => 'Related tag',
                    'name' => 'related_tag',
                    'type' => 'taxonomy',
                    'instructions' => '',
                    'required' => 0,
                    'conditional_logic' => 0,
                    'wrapper' => array(
                        'width' => '',
                        'class' => '',
                        'id' => '',
                    ),
                    'taxonomy' => 'post_tag',
                    'field_type' => 'multi_select',
                    'allow_null' => 0,
                    'add_term' => 0,
                    'save_terms' => 0,
                    'load_terms' => 1,
                    'return_format' => 'id',
                    'multiple' => 0,
                ),
                array(
                    'key'               => 'field_5cbfe272c9326',
                    'label'             => 'Block title',
                    'name'              => 'block_title',
                    'type'              => 'text',
                    'instructions'      => 'The title to use eg: "More Insights". Defaults to "Related".',
                    'required'          => 0,
                    'conditional_logic' => 0,
                    'wrapper'           => array(
                        'width' => '',
                        'class' => '',
                        'id'    => '',
                    ),
                    'default_value'     => 'Related',
                    'placeholder'       => '',
                    'prepend'           => '',
                    'append'            => '',
                    'maxlength'         => '',
                ),
            ),
            'location'              => array(
                array(
                    array(
                        'param'    => 'block',
                        'operator' => '==',
                        'value'    => 'acf/related',
                    ),
                ),
            ),
            'menu_order'            => 0,
            'position'              => 'acf_after_title',
            'style'                 => 'seamless',
            'label_placement'       => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen'        => '',
            'active'                => true,
            'description'           => '',
        ));
    

    Now out of this post and title works but tag doesn’t. Why? Because it’s not recognised by ACF. Here’s test post content:

    <!-- wp:acf/related {"id":"block_60055cc22371a","name":"acf/related","data":{"related_case_studies":["16043"],"_related_case_studies":"field_5cbe88701e944","related_tag":["240"],"_related_tag":"field_5cbe43102f4e6","block_title":"Related","_block_title":"field_5cbfe272c9326"},"align":"","mode":"preview"} /-->
    

    When admin page loads, case study field preloads with the right article, but tag field doesn’t – it’s empty on the sidebar. And the ID is correct 240 is correct taxonomy ID. Any hints?

  • Unread

    Filter location using taxonomy

    I am try to add location filed to my website, I used ACF to add the dropdown. And its working fine. I can get the selected location to product publish page. My problem is I cant check the location in taxonomy.(please check the screen shot 1)

    I cant filter the items by location because of this reason.

    please some one help me I’m stuck in this issue very long time.

    Thanks for your time!!

  • Unread

    ACF Form taxonomy field and Buddypress conflict

    Hi when I have buddypress enabled, my acf_form taxonomies doesn’t show any results when the dropdown is selected, it says ‘The results could not be loaded’, of i disable the buddypress plugin the taxonomy dropdowns show as expected. I have a page template which has the following code:

    <?php 
    function returnHome(){
    		wp_redirect( esc_url( home_url( '/' ) ) ); 
    		exit; 
    	}
    
    //if ( !is_user_logged_in() ) returnHome();
    
    acf_form_head();
    get_header();
    
    ?>
    
    <?php
    /**
     * Template Name: Load Submission Form
     */
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    	<div class="entry-content container">
    		<?php the_content(); ?>
        </div>
     </article>
     
     <section>
     	<div class="container">
     	
    	<?php if ( ($_GET['updated'] == 'true' || $_GET['do-register'] == 'true') ) {
    		
    		//once updated, return to homepage 
    		echo '<p><a href="'.esc_url( home_url( '/' )) .'">Return to homepage</a>';
    
    		returnHome();
    	
    	} else { 
    
    		// show form ?>
    
    					<form autocomplete="off" enctype="multipart/form-data" name="registerform" id="registerform" action="<?php echo get_permalink() . '?do-register=true' ?>" method="post">
    			
    					<?php
    						$args = array(
    							'post_id' 	   => "new_post",
    							'field_groups' => array(62),
    							'updated_message' => false,
    							'new_post'		=> array(
    								'post_title'		=> true,
    								'post_title_label'   => $_POST['acf']['field_5ff5921bc7f1c'] . " - " . $_POST['acf']['field_5ff59276c7f1d'] . "Date:" . $_POST['acf']['field_5ff5869624818'] . "-" . $_POST['acf']['field_5ff586ba24819'],
    								'post_type'		=> 'loads',
    								'post_status'	=> 'publish'
    							),
    							'submit_value' => __("Register Load", 'acf')
    					
    						);
    						
    						acf_form($args); ?>
    
    					</form>
    			<?php } ?>
    
    	</div><!-- .entry-content -->
    </article><!-- #post-<?php the_ID(); ?> -->
    
    <?php get_footer(); ?>
  • Solving

    How to add a search feature to ACF checkbox hierarchy

    Hello, I have created a fairly extensive anatomy hierarchy in ACF PRO for a medical site. This is a taxonomy set to display as checkboxes. The user needs to check the anatomy that a particular post relates to. The problem is that the anatomy list is very long, and users cannot find the item(s) they need. Is there a way in ACF to add a search feature when a taxonomy is displayed as checkboxes?

    I am familiar with displaying the taxonomy as as select field, which is then searchable. However, once you start searching, the user cannot see the rest of the hierarchy, and they are required to select all of the parents of the child elements. So I need them to be able to see the entire hierarchy the whole time. Basically I need the same thing a browser search does, but only in the one field area (not in the whole browser).

    Example:
    MSK
    – Knee
    – – Miniscus
    – Hand
    – – Finger
    – – Thumb

    When a user selects “Finger”, they are also required to select “Hand” and “MSK”. So searching for Finger in a select box doesn’t work, b/c they often do not know the name of a parent element that must be selected also. (I’m using easy-to-read examples here. Many of the items are using medical terminology that isn’t easy to read or remember).

  • Helping

    Add Term "plus" button for Taxonomy Field missing

    Hello,

    I want the “plus” button to display all the time, so users know its there and so users on mobile can see it at all.

    The default is on hover, but cant figure out how to change it, im trying with some CSS but with no success whatsoever.

    Id appretiate any help 😀

  • Unread

    Getting ACF Select field Label for a given Value

    I’ve written a function that uses SQL to give me a count of the distinct values of bl-project.ptype, where bl-project is a custom taxonomy and ptype is an ACF select field containing value : label pairs. The function works well, but returns values for ptype and I’d prefer labels.

    There are a couple of similar threads on this topic but the solutions therein don’t seem to work unless you’re on a post detail page, whereas I need a value -> label lookup function that works independent of a post or taxonomy.*

    So far I’m getting around this by maintaining a lookup function in PHP which takes the select value as input and returns the label value as output, but maintaining this function in parallel with the ACF Select field is a recipe for disaster. Thinking that I could adapt my original SQL function to incorporate a lookup I did a search for one of my select field values, and the only place it appears in the WP DB is in the wp_posts entry which appears to describe my ACF Select field, and I can’t work out the format in which it’s stored.

    As always, many thanks in advance for any assistance.

    * Incidentally, get_field_object() doesn’t seem to work on select fields against a custom taxonomy, only those against a custom post type. Not sure if this is intentional.

  • Solving

    Loop to call Category Custom Fields using a taxonomy selection field

    Hi

    I am building a client site which uses the category taxonomy to control the content displayed. I have added custom fields to each category and would like to display them on individual pages.

    I can call the custom fields to the category archives but am struggling to get them into a loop. 

On the landing page I have a taxonomy field that selects the categories to display. I can get the category names to display using the loop below but have been unable to successfully use get_field or an array to call a custom field below the <h5> tags.

    I have found a number of topics relating to the problem but nothing that quite recreates this issue.

    <?php 
                            $terms = get_field('featured_topics');
    
                            if( $terms ): ?>
                            <?php foreach( $terms as $term ):
                            
                            ?>
           
            <h5 class="text-center"><?php echo esc_html( $term->name ); ?></h5>
                <?php endforeach; ?>
                <?php endif; ?>

    Any help or relevant articles gratefully received. 


    
Thanks

  • Solved

    Using compare IN operator for meta_query

    I am using a custom post type with large amount of custom fields and I’ve created a listing page for the fields with the options of filtering and sorting. The taxonomy filters are working fine, I need help with ACF fields meta_query since the data is stored in serialized form I’m having trouble querying it with the compare ‘IN’ operator.

    I have already done quite a bit of research most of which suggested using multiple arrays for key/value combination. That approach is however not feasible since I have large amount of fields to use as filters.

    foreach($metaFilters as $key=>$metaFilter){
     $metaQuery[] = array(
     'key' => $key, 
     'value' => $metaFilter,
     'compare' => 'IN'
      );
     }

    This is how I’m using the meta_query for now which of course is not working. Please assist me with the issue.. if there’s no solution I’d love to hear the best approach available for this.

  • Unread

    Mixing foreach and while loops

    Hi guys,

    I am having trouble with getting some code to play nice.

    Here is the setup: (I am working in the latest WordPress with the latest version of ACF PRO)
    I have created a page and have a repeater on it with 3 subfields. One of these subfields pulls in the general taxonomies under post.

    I need to output each taxonomy individually and then check to see if any of the rows have an entry for that taxonomy.

    Here is an example (each city is a taxonomy):
    Worker A will travel to City A, City B, and City C
    Worker B will travel to City B and City C
    Worker C will travel to City A and City C

    Desired Output
    City A
    Worker A
    Worker C

    City B
    Worker A
    Worker B

    City C
    Worker A
    Worker B
    Worker C

    Currently, it just repeats all names under each taxonomy. Please help (please and thank you)!

    <?php // get regular list of tags and during the foreach, check to see if there is a reviewer for that tag / run rows then if genre == that term, proceed
    
    						$tags = get_tags(array(
    							'hide_empty' => false
    							));
    							echo '<ul>';
    								foreach ($tags as $tag) {
    									
    									echo '<li>';
    									
    										echo $tag->name;
    									 	
    									
    												if( have_rows('reviewer_info') ):
    												echo '<ul>';
    													while ( have_rows('reviewer_info') ) : the_row();
    														echo '<li>';
    																echo the_sub_field('reviewer_name');
    														echo '</li>';
    													endwhile;
    												echo '</ul>';
    												endif;
    									
    									echo '</li>';
    								}
    							echo '</ul>'; ?>
  • Helping

    Scraping with ACF Pro?

    I have a website which is going to be recommending books.

    I want a custom field where I enter the Amazon URL, and I get back the following data automatically:

    Book title (to be set as post title) Book author (to be added to ‘Authors’ custom taxonomy) Book image (to be set as featured image) Book genre (to be added to ‘Genres’ custom taxonomy) Book description (to be added to custom field)

    Is there a way to achieve this with ACF Pro? I thought maybe oEmbed would be the way to go about it, but I’m not having a lot of luck there.

    Does anyone have any suggestions?

  • Helping

    Customising Taxonomy Field (Checkbox)

    I am looking for a way to customise the Taxonomy Field (when displayed as a Checkbox).

    That taxonomy field- let’s call it Collections- used to contain terms that were all applicable to the Current Content item (where the that taxonomy field appears), let’s call it Cars — and all those Cars were considered Modern (see below), but with no specific distinction in the database.

    Recently, after an update to the whole content structure, we have added also Old Cars – and now we are distinguish Modern/Old cars by another taxonomy field for those 2 options.

    So a Car can be set either as Modern or Old.

    Now for the Collections: All existing collections terms were for the Modern Cars.
    With the addition of the Old cars a few existing Collections might also be applicable for the them, but we will also create new Collections exclusively for them.

    So foreach collection term, there will be an extra field to set that term either for Modern, Old, or Both.

    Now, in the Cars Edit page, where the Fields:
    – Set the car as Modern or Old (dropdown select).
    – Taxonomy Checkbox field for setting each to 0,1 or more collections.

    I want to display only the collections that are applicable to Modern or Old cars, based on the selection of the first field.

    Ideally that would be an AJAX call to update the checkboxes.

    Or at least I would be also happy if there was a way to add classes to each checkbox instance of the collections field, based on its assignment (old/modern/ old-modern)…

    Is there any way to manipulate the Taxonomy field like this?

  • Unread

    Caching taxonomy term fields

    Hi. Love ACF Pro!

    I’m using acf_form() to create front-end forms. Couldn’t be happier. Well, I could :). If only I could find a way to speed up the loading of the terms in the taxonomy dropdowns.

    I am using taxonomy field types with appearance option as “select” or “multi select”. On the front end, in the acf form, when I click a field to select a taxonomy term, I get the “searching” text and it takes a bit for the terms to show in the selector. Is there any way to cache this ?

  • Solving

    Trying to display a category (taxonomy) field in the fronted

    Trying to display a category (taxonomy) field added to a custom post, for it’s single page. My code in the cntent template goes like this, but it return nothing.

    <li>Plan type : <?php the_field('plan_type'); ?><li>

    The field is configured like this (see pic attached).

  • Unread

    How to make a Front End search Form with ACF

    I have looked for more than 2 Weeks how to make a Search and Filter Function using ACF Fields and I have finally Made it using this Code which I would love to share it with you.

    First university-search.php

    <?php
     $is_search = count( $_GET );
        $university_studyfield = get_terms([
                'taxonomy' => 'university_studyfield',
                'hide_empty' => false,
        ]);
        $study_degree = get_terms([
                'taxonomy' => 'study_degree',
                'hide_empty' => false,
        ]);
     $university_location = get_terms([
                'taxonomy' => 'university_location',
                'hide_empty' => false,
        ]);
      
    ?>
    <div class="container">
           <form action="<?php echo home_url('/');?>">
      <div class="row form-group  " style="justify-content: center;">
       
     
             <div class="col-lg-4"> 
    
                   
                    <select name="university_studyfield" class="form-control">
    
                            <option value=""><?php _e('Study Field','studyshoot'); ?></option>
    
                            <?php foreach($university_studyfield as $university_studyfield):?>
                                    <option 
                                    
                                    <?php if(  isset($_GET['university_studyfield']) && ( $_GET['university_studyfield'] == $university_studyfield->slug)  ):?>
                                        selected
                                    <?php endif;?>
    
                                    value="<?php echo $university_studyfield->slug;?>"><?php echo $university_studyfield->name;?></option>
                            <?php endforeach;?>
    
                    </select>
                
                </div>
     <div class="col-lg-4"> 
                    
                
                    <select name="study_degree" class="form-control">
    
                            <option value=""><?php _e('  Degree  ','studyshoot'); ?> </option>
    
                            <?php foreach($study_degree as $study_degree):?>
                                    <option 
                                    
                                    <?php if(  isset($_GET['study_degree']) && ( $_GET['study_degree'] == $type->slug)  ):?>
                                        selected
                                    <?php endif;?>
    
                                    value="<?php echo $study_degree->slug;?>"><?php echo $study_degree->name;?></option>
                            <?php endforeach;?>
    
                    </select>
                
      </div>   
     
             <div class="col-lg-4"> 
    
                  
                
                    <select name="university_location" class="form-control">
    
                            <option value=""><?php _e('  Location   ','immobilien'); ?></option>
    
                            <?php foreach($university_location as $university_location):?>
                                    <option 
                                    
                                    <?php if(  isset($_GET['university_location']) && ( $_GET['university_location'] == $university_location->slug)  ):?>
                                        selected
                                    <?php endif;?>
    
                                    value="<?php echo $university_location->slug;?>"><?php echo $university_location->name;?></option>
                            <?php endforeach;?>
    
                    </select>
                
                </div>
                </div>
            <button type="submit" class="new-btn-one btn-block "><?php _e('Search Now ','studyshoot'); ?> </button>
         
            
    
                </form>
    </div>
     
    <br><br>
     

    Then Functions.php

    
    function search_query()
    {
    
        $paged = ( get_query_var('paged')  )  ? get_query_var('paged') : 1; 
    
        $args = [
    
            'paged' => $paged,
            'post_type' =>  array('grants','_'),
            'tax_query' => [],
     
    
        ];
    
     
    
         if( isset($_GET['university_studyfield']) )
        {
            if(!empty($_GET['university_studyfield']))
            {
                $args['tax_query'][] = [
    
                        'taxonomy' =>  'university_studyfield',
                        'field' => 'slug',
                        'terms' => array( sanitize_text_field( $_GET['university_studyfield'] ) )
    
                ];
            }
        }
    
     
    
         if( isset($_GET['study_degree']) )
        {
            if(!empty($_GET['study_degree']))
            {
                $args['tax_query'][] = [
    
                        'taxonomy' =>  'study_degree',
                        'field' => 'slug',
                        'terms' => array( sanitize_text_field( $_GET['study_degree'] ) )
    
                ];
            }
        }
    
             if( isset($_GET['university_location']) )
        {
            if(!empty($_GET['university_location']))
            {
                $args['tax_query'][] = [
    
                        'taxonomy' =>  'university_location',
                        'field' => 'slug',
                        'terms' => array( sanitize_text_field( $_GET['university_location'] ) )
    
                ];
            }
        }
     
     
    
        return  new WP_Query($args);
    
    }
    

    Then I generate the Shortcode to use it in My Template:

    I still need a Tutorial where I can learn how to make it with ajax a live search. also as you see I used the Custom Taxonomy field to do that…. How do I replace the Taxonomy with ACF Select field if is it Possoble

    Thanks for all who are working at ACF, It is a Great one

  • Solving

    Specific Fields for specific taxonomies on Archive Page

    Hi there,
    I’ve been reading through Forum to see if I can find an answer to the issue I’m having. Found some similar ones but got lost in the code, (not very good at it) and each with their own issues. So here is my issue I need some ideas for please:

    I have a CPT called Listings and one of the taxonomies I created for it is ‘Land-Plot’.
    I was able to create different acf fields and show them with conditional logic at the back end.
    For example, if cpt taxonomy is ‘Land plot’ show these fields, etc.
    This is working fine at the back end, but:

    I have created an archive page where all my Listings live.
    I can show whatever acf I created through Dynamic Fields for Elementor PRO, so no problem.

    In each listing type on the archives page, I have an extra toggle section, where in there I display a set of 2-3 different extra attributes of that listing type.

    One of the specific fields I created for this section is, ‘Land Type’

    While I can select it when editing my Listing Archive Page, what happens is it shows this particular acf in all other listing types as well, regardless of their taxonomy. So when I open the toggle area, the content is the same, regardless of the listing type.

    For example, listings with a taxonomy called ‘Houses’ show the ‘land-only’ custom field in the toggle area, instead of ‘House-only’ field, and vice versa.

    Hope I’m making sense here??
    How can I have my archive page, populate the specific custom fields in their respective listing types??

    A further example for archive page in front-end:
    1) Listing type: House
    Toggle area: Bedrooms: 3
    2) Listing type: Land-Plot
    Toggle area: Land type: even

    Thank you in advance for your time and suggestions!

Viewing 25 results - 476 through 500 (of 3,191 total)